/* A Bison parser, made by GNU Bison 3.7.4.  */

/* Bison implementation for Yacc-like parsers in C

   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
   Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* As a special exception, you may create a larger work that contains
   part or all of the Bison parser skeleton and distribute that work
   under terms of your choice, so long as that work isn't itself a
   parser generator using the skeleton or a modified version thereof
   as a parser skeleton.  Alternatively, if you modify or redistribute
   the parser skeleton itself, you may (at your option) remove this
   special exception, which will cause the skeleton and the resulting
   Bison output files to be licensed under the GNU General Public
   License without this special exception.

   This special exception was added by the Free Software Foundation in
   version 2.2 of Bison.  */

/* C LALR(1) parser skeleton written by Richard Stallman, by
   simplifying the original so-called "semantic" parser.  */

/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
   especially those whose name start with YY_ or yy_.  They are
   private implementation details that can be changed or removed.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Identify Bison output, and Bison version.  */
#define YYBISON 30704

/* Bison version string.  */
#define YYBISON_VERSION "3.7.4"

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 2

/* Push parsers.  */
#define YYPUSH 0

/* Pull parsers.  */
#define YYPULL 1

/* Substitute the type names.  */
#define YYSTYPE         MENT_STYPE
#define YYLTYPE         MENT_LTYPE
/* Substitute the variable and function names.  */
#define yyparse         ment_parse
#define yylex           ment_lex
#define yyerror         ment_error
#define yydebug         ment_debug
#define yynerrs         ment_nerrs

/* First part of user prologue.  */
#line 1 "bison_parser.y"

/**
 * bison_parser.y
 * defines bison_parser.h
 * outputs bison_parser.c
 *
 * Grammar File Spec: http://dinosaur.compilertools.net/bison/bison_6.html
 *
 */
/*********************************
 ** Section 1: C Declarations
 *********************************/

#include "bison_parser.hpp"
#include "bison_parser.h"
#include "flex_lexer.h"

#include <stdio.h>
#include <string.h>

using namespace ment;

extern char g_typoBuf[];

int yyerror(YYLTYPE* llocp, SQLParserResult* result, yyscan_t scanner, const char* msg) {
	if (g_typoBuf[0]) {      // 如果 lexer 已填好 typo 信息
        result->setIsValid(false);
        result->setErrorDetails(strdup(g_typoBuf), llocp->first_line, llocp->first_column);
        g_typoBuf[0] = '\0'; // 用完清空
        return 0;
    }
    result->setIsValid(false);

    const char* cur = (ment_char == 0) ? "EOF" : ment_token_to_string(ment_char);

    char buf[512];
    if (strstr(msg, "unexpected") != NULL && strstr(msg, "end of file") != NULL) {
        snprintf(buf, sizeof(buf),
                 "Syntax error at line %d, column %d: Missing closing quote or bracket",
                 llocp->first_line, llocp->first_column);
    } else if (strstr(msg, "unexpected") != NULL && strstr(msg, "IDENTIFIER") != NULL) {
        snprintf(buf, sizeof(buf),
                 "Syntax error at line %d, column %d: Missing comma or closing parenthesis",
                 llocp->first_line, llocp->first_column);
    } else {
        snprintf(buf, sizeof(buf),
                 "Syntax error at line %d, column %d: %s ",
                 llocp->first_line, llocp->first_column, msg, cur);
    }

    result->setErrorDetails(strdup(buf), llocp->first_line, llocp->first_column);
    return 0;
}

struct yyguts_t;

int ment_lex(YYSTYPE* yylval_param, YYLTYPE* yylloc_param, yyscan_t yyscanner);



static std::vector<std::pair<int,int>> *g_insertColPos = nullptr;

std::vector<std::pair<std::string, std::pair<int,int>>> g_colPos;
std::vector<std::pair<int,int>> g_valuePos;

extern bool g_colPosMoved;

bool g_colPosMoved = false;


#line 149 "bison_parser.cpp"

# ifndef YY_CAST
#  ifdef __cplusplus
#   define YY_CAST(Type, Val) static_cast<Type> (Val)
#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
#  else
#   define YY_CAST(Type, Val) ((Type) (Val))
#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
#  endif
# endif
# ifndef YY_NULLPTR
#  if defined __cplusplus
#   if 201103L <= __cplusplus
#    define YY_NULLPTR nullptr
#   else
#    define YY_NULLPTR 0
#   endif
#  else
#   define YY_NULLPTR ((void*)0)
#  endif
# endif

#include "bison_parser.h"
/* Symbol kind.  */
enum yysymbol_kind_t
{
  YYSYMBOL_YYEMPTY = -2,
  YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
  YYSYMBOL_YYerror = 1,                    /* error  */
  YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
  YYSYMBOL_IDENTIFIER = 3,                 /* IDENTIFIER  */
  YYSYMBOL_STRING = 4,                     /* STRING  */
  YYSYMBOL_FLOATVAL = 5,                   /* FLOATVAL  */
  YYSYMBOL_INTVAL = 6,                     /* INTVAL  */
  YYSYMBOL_SQL_ILLEGAL = 7,                /* SQL_ILLEGAL  */
  YYSYMBOL_BOOL = 8,                       /* BOOL  */
  YYSYMBOL_PRIMARY_KEY = 9,                /* PRIMARY_KEY  */
  YYSYMBOL_DEALLOCATE = 10,                /* DEALLOCATE  */
  YYSYMBOL_PARAMETERS = 11,                /* PARAMETERS  */
  YYSYMBOL_INTERSECT = 12,                 /* INTERSECT  */
  YYSYMBOL_TEMPORARY = 13,                 /* TEMPORARY  */
  YYSYMBOL_TIMESTAMP = 14,                 /* TIMESTAMP  */
  YYSYMBOL_DISTINCT = 15,                  /* DISTINCT  */
  YYSYMBOL_NVARCHAR = 16,                  /* NVARCHAR  */
  YYSYMBOL_RESTRICT = 17,                  /* RESTRICT  */
  YYSYMBOL_TRUNCATE = 18,                  /* TRUNCATE  */
  YYSYMBOL_ANALYZE = 19,                   /* ANALYZE  */
  YYSYMBOL_BETWEEN = 20,                   /* BETWEEN  */
  YYSYMBOL_CASCADE = 21,                   /* CASCADE  */
  YYSYMBOL_COLUMNS = 22,                   /* COLUMNS  */
  YYSYMBOL_CONTROL = 23,                   /* CONTROL  */
  YYSYMBOL_DEFAULT = 24,                   /* DEFAULT  */
  YYSYMBOL_EXECUTE = 25,                   /* EXECUTE  */
  YYSYMBOL_EXPLAIN = 26,                   /* EXPLAIN  */
  YYSYMBOL_HISTORY = 27,                   /* HISTORY  */
  YYSYMBOL_INTEGER = 28,                   /* INTEGER  */
  YYSYMBOL_NATURAL = 29,                   /* NATURAL  */
  YYSYMBOL_PREPARE = 30,                   /* PREPARE  */
  YYSYMBOL_PRIMARY = 31,                   /* PRIMARY  */
  YYSYMBOL_SCHEMAS = 32,                   /* SCHEMAS  */
  YYSYMBOL_SPATIAL = 33,                   /* SPATIAL  */
  YYSYMBOL_VARCHAR = 34,                   /* VARCHAR  */
  YYSYMBOL_VIRTUAL = 35,                   /* VIRTUAL  */
  YYSYMBOL_BEFORE = 36,                    /* BEFORE  */
  YYSYMBOL_COLUMN = 37,                    /* COLUMN  */
  YYSYMBOL_CREATE = 38,                    /* CREATE  */
  YYSYMBOL_DELETE = 39,                    /* DELETE  */
  YYSYMBOL_DIRECT = 40,                    /* DIRECT  */
  YYSYMBOL_DOUBLE = 41,                    /* DOUBLE  */
  YYSYMBOL_ESCAPE = 42,                    /* ESCAPE  */
  YYSYMBOL_EXCEPT = 43,                    /* EXCEPT  */
  YYSYMBOL_EXISTS = 44,                    /* EXISTS  */
  YYSYMBOL_EXTRACT = 45,                   /* EXTRACT  */
  YYSYMBOL_GLOBAL = 46,                    /* GLOBAL  */
  YYSYMBOL_HAVING = 47,                    /* HAVING  */
  YYSYMBOL_IMPORT = 48,                    /* IMPORT  */
  YYSYMBOL_INSERT = 49,                    /* INSERT  */
  YYSYMBOL_ISNULL = 50,                    /* ISNULL  */
  YYSYMBOL_OFFSET = 51,                    /* OFFSET  */
  YYSYMBOL_RENAME = 52,                    /* RENAME  */
  YYSYMBOL_SCHEMA = 53,                    /* SCHEMA  */
  YYSYMBOL_SELECT = 54,                    /* SELECT  */
  YYSYMBOL_SORTED = 55,                    /* SORTED  */
  YYSYMBOL_TABLES = 56,                    /* TABLES  */
  YYSYMBOL_UNIQUE = 57,                    /* UNIQUE  */
  YYSYMBOL_UNLOAD = 58,                    /* UNLOAD  */
  YYSYMBOL_UPDATE = 59,                    /* UPDATE  */
  YYSYMBOL_VALUES = 60,                    /* VALUES  */
  YYSYMBOL_AFTER = 61,                     /* AFTER  */
  YYSYMBOL_ALTER = 62,                     /* ALTER  */
  YYSYMBOL_CROSS = 63,                     /* CROSS  */
  YYSYMBOL_DELTA = 64,                     /* DELTA  */
  YYSYMBOL_FLOAT = 65,                     /* FLOAT  */
  YYSYMBOL_GROUP = 66,                     /* GROUP  */
  YYSYMBOL_INDEX = 67,                     /* INDEX  */
  YYSYMBOL_INNER = 68,                     /* INNER  */
  YYSYMBOL_LIMIT = 69,                     /* LIMIT  */
  YYSYMBOL_LOCAL = 70,                     /* LOCAL  */
  YYSYMBOL_MERGE = 71,                     /* MERGE  */
  YYSYMBOL_MINUS = 72,                     /* MINUS  */
  YYSYMBOL_ORDER = 73,                     /* ORDER  */
  YYSYMBOL_OUTER = 74,                     /* OUTER  */
  YYSYMBOL_RIGHT = 75,                     /* RIGHT  */
  YYSYMBOL_TABLE = 76,                     /* TABLE  */
  YYSYMBOL_UNION = 77,                     /* UNION  */
  YYSYMBOL_USING = 78,                     /* USING  */
  YYSYMBOL_WHERE = 79,                     /* WHERE  */
  YYSYMBOL_CALL = 80,                      /* CALL  */
  YYSYMBOL_CASE = 81,                      /* CASE  */
  YYSYMBOL_CHAR = 82,                      /* CHAR  */
  YYSYMBOL_DATE = 83,                      /* DATE  */
  YYSYMBOL_DESC = 84,                      /* DESC  */
  YYSYMBOL_DROP = 85,                      /* DROP  */
  YYSYMBOL_ELSE = 86,                      /* ELSE  */
  YYSYMBOL_FILE = 87,                      /* FILE  */
  YYSYMBOL_FROM = 88,                      /* FROM  */
  YYSYMBOL_FULL = 89,                      /* FULL  */
  YYSYMBOL_HASH = 90,                      /* HASH  */
  YYSYMBOL_HINT = 91,                      /* HINT  */
  YYSYMBOL_INTO = 92,                      /* INTO  */
  YYSYMBOL_JOIN = 93,                      /* JOIN  */
  YYSYMBOL_LEFT = 94,                      /* LEFT  */
  YYSYMBOL_LIKE = 95,                      /* LIKE  */
  YYSYMBOL_LOAD = 96,                      /* LOAD  */
  YYSYMBOL_LONG = 97,                      /* LONG  */
  YYSYMBOL_NULL = 98,                      /* NULL  */
  YYSYMBOL_PLAN = 99,                      /* PLAN  */
  YYSYMBOL_SHOW = 100,                     /* SHOW  */
  YYSYMBOL_TEXT = 101,                     /* TEXT  */
  YYSYMBOL_THEN = 102,                     /* THEN  */
  YYSYMBOL_TIME = 103,                     /* TIME  */
  YYSYMBOL_VIEW = 104,                     /* VIEW  */
  YYSYMBOL_WHEN = 105,                     /* WHEN  */
  YYSYMBOL_WITH = 106,                     /* WITH  */
  YYSYMBOL_ADD = 107,                      /* ADD  */
  YYSYMBOL_ALL = 108,                      /* ALL  */
  YYSYMBOL_AND = 109,                      /* AND  */
  YYSYMBOL_ASC = 110,                      /* ASC  */
  YYSYMBOL_CSV = 111,                      /* CSV  */
  YYSYMBOL_END = 112,                      /* END  */
  YYSYMBOL_FOR = 113,                      /* FOR  */
  YYSYMBOL_INT = 114,                      /* INT  */
  YYSYMBOL_KEY = 115,                      /* KEY  */
  YYSYMBOL_NOT = 116,                      /* NOT  */
  YYSYMBOL_OFF = 117,                      /* OFF  */
  YYSYMBOL_SET = 118,                      /* SET  */
  YYSYMBOL_TBL = 119,                      /* TBL  */
  YYSYMBOL_TOP = 120,                      /* TOP  */
  YYSYMBOL_AS = 121,                       /* AS  */
  YYSYMBOL_BY = 122,                       /* BY  */
  YYSYMBOL_IF = 123,                       /* IF  */
  YYSYMBOL_IN = 124,                       /* IN  */
  YYSYMBOL_IS = 125,                       /* IS  */
  YYSYMBOL_OF = 126,                       /* OF  */
  YYSYMBOL_ON = 127,                       /* ON  */
  YYSYMBOL_OR = 128,                       /* OR  */
  YYSYMBOL_TO = 129,                       /* TO  */
  YYSYMBOL_ARRAY = 130,                    /* ARRAY  */
  YYSYMBOL_CONCAT = 131,                   /* CONCAT  */
  YYSYMBOL_ILIKE = 132,                    /* ILIKE  */
  YYSYMBOL_SECOND = 133,                   /* SECOND  */
  YYSYMBOL_MINUTE = 134,                   /* MINUTE  */
  YYSYMBOL_HOUR = 135,                     /* HOUR  */
  YYSYMBOL_DAY = 136,                      /* DAY  */
  YYSYMBOL_MONTH = 137,                    /* MONTH  */
  YYSYMBOL_YEAR = 138,                     /* YEAR  */
  YYSYMBOL_TRUE = 139,                     /* TRUE  */
  YYSYMBOL_FALSE = 140,                    /* FALSE  */
  YYSYMBOL_DATABASES = 141,                /* DATABASES  */
  YYSYMBOL_USE = 142,                      /* USE  */
  YYSYMBOL_143_ = 143,                     /* '='  */
  YYSYMBOL_EQUALS = 144,                   /* EQUALS  */
  YYSYMBOL_NOTEQUALS = 145,                /* NOTEQUALS  */
  YYSYMBOL_146_ = 146,                     /* '<'  */
  YYSYMBOL_147_ = 147,                     /* '>'  */
  YYSYMBOL_LESS = 148,                     /* LESS  */
  YYSYMBOL_GREATER = 149,                  /* GREATER  */
  YYSYMBOL_LESSEQ = 150,                   /* LESSEQ  */
  YYSYMBOL_GREATEREQ = 151,                /* GREATEREQ  */
  YYSYMBOL_NOTNULL = 152,                  /* NOTNULL  */
  YYSYMBOL_153_ = 153,                     /* '+'  */
  YYSYMBOL_154_ = 154,                     /* '-'  */
  YYSYMBOL_155_ = 155,                     /* '*'  */
  YYSYMBOL_156_ = 156,                     /* '/'  */
  YYSYMBOL_157_ = 157,                     /* '%'  */
  YYSYMBOL_158_ = 158,                     /* '^'  */
  YYSYMBOL_UMINUS = 159,                   /* UMINUS  */
  YYSYMBOL_160_ = 160,                     /* '['  */
  YYSYMBOL_161_ = 161,                     /* ']'  */
  YYSYMBOL_162_ = 162,                     /* '('  */
  YYSYMBOL_163_ = 163,                     /* ')'  */
  YYSYMBOL_164_ = 164,                     /* '.'  */
  YYSYMBOL_165_ = 165,                     /* ';'  */
  YYSYMBOL_166_ = 166,                     /* ','  */
  YYSYMBOL_167_ = 167,                     /* '?'  */
  YYSYMBOL_YYACCEPT = 168,                 /* $accept  */
  YYSYMBOL_input = 169,                    /* input  */
  YYSYMBOL_statement_list = 170,           /* statement_list  */
  YYSYMBOL_statement = 171,                /* statement  */
  YYSYMBOL_preparable_statement = 172,     /* preparable_statement  */
  YYSYMBOL_opt_hints = 173,                /* opt_hints  */
  YYSYMBOL_hint_list = 174,                /* hint_list  */
  YYSYMBOL_hint = 175,                     /* hint  */
  YYSYMBOL_prepare_statement = 176,        /* prepare_statement  */
  YYSYMBOL_prepare_target_query = 177,     /* prepare_target_query  */
  YYSYMBOL_execute_statement = 178,        /* execute_statement  */
  YYSYMBOL_import_statement = 179,         /* import_statement  */
  YYSYMBOL_import_file_type = 180,         /* import_file_type  */
  YYSYMBOL_file_path = 181,                /* file_path  */
  YYSYMBOL_show_statement = 182,           /* show_statement  */
  YYSYMBOL_use_statement = 183,            /* use_statement  */
  YYSYMBOL_create_statement = 184,         /* create_statement  */
  YYSYMBOL_opt_not_exists = 185,           /* opt_not_exists  */
  YYSYMBOL_column_def_commalist = 186,     /* column_def_commalist  */
  YYSYMBOL_column_def = 187,               /* column_def  */
  YYSYMBOL_column_type = 188,              /* column_type  */
  YYSYMBOL_opt_column_nullable = 189,      /* opt_column_nullable  */
  YYSYMBOL_opt_primary_key = 190,          /* opt_primary_key  */
  YYSYMBOL_drop_statement = 191,           /* drop_statement  */
  YYSYMBOL_opt_exists = 192,               /* opt_exists  */
  YYSYMBOL_delete_statement = 193,         /* delete_statement  */
  YYSYMBOL_truncate_statement = 194,       /* truncate_statement  */
  YYSYMBOL_insert_statement = 195,         /* insert_statement  */
  YYSYMBOL_opt_column_list = 196,          /* opt_column_list  */
  YYSYMBOL_update_statement = 197,         /* update_statement  */
  YYSYMBOL_update_clause_commalist = 198,  /* update_clause_commalist  */
  YYSYMBOL_update_clause = 199,            /* update_clause  */
  YYSYMBOL_select_statement = 200,         /* select_statement  */
  YYSYMBOL_select_with_paren = 201,        /* select_with_paren  */
  YYSYMBOL_select_paren_or_clause = 202,   /* select_paren_or_clause  */
  YYSYMBOL_select_no_paren = 203,          /* select_no_paren  */
  YYSYMBOL_set_operator = 204,             /* set_operator  */
  YYSYMBOL_set_type = 205,                 /* set_type  */
  YYSYMBOL_opt_all = 206,                  /* opt_all  */
  YYSYMBOL_select_clause = 207,            /* select_clause  */
  YYSYMBOL_opt_distinct = 208,             /* opt_distinct  */
  YYSYMBOL_select_list = 209,              /* select_list  */
  YYSYMBOL_opt_from_clause = 210,          /* opt_from_clause  */
  YYSYMBOL_from_clause = 211,              /* from_clause  */
  YYSYMBOL_opt_where = 212,                /* opt_where  */
  YYSYMBOL_opt_group = 213,                /* opt_group  */
  YYSYMBOL_opt_having = 214,               /* opt_having  */
  YYSYMBOL_opt_order = 215,                /* opt_order  */
  YYSYMBOL_order_list = 216,               /* order_list  */
  YYSYMBOL_order_desc = 217,               /* order_desc  */
  YYSYMBOL_opt_order_type = 218,           /* opt_order_type  */
  YYSYMBOL_opt_top = 219,                  /* opt_top  */
  YYSYMBOL_opt_limit = 220,                /* opt_limit  */
  YYSYMBOL_stat_list = 221,                /* stat_list  */
  YYSYMBOL_literal_list = 222,             /* literal_list  */
  YYSYMBOL_stat_alias = 223,               /* stat_alias  */
  YYSYMBOL_stat = 224,                     /* stat  */
  YYSYMBOL_operand = 225,                  /* operand  */
  YYSYMBOL_scalar_stat = 226,              /* scalar_stat  */
  YYSYMBOL_unary_stat = 227,               /* unary_stat  */
  YYSYMBOL_binary_stat = 228,              /* binary_stat  */
  YYSYMBOL_logic_stat = 229,               /* logic_stat  */
  YYSYMBOL_in_stat = 230,                  /* in_stat  */
  YYSYMBOL_case_stat = 231,                /* case_stat  */
  YYSYMBOL_case_list = 232,                /* case_list  */
  YYSYMBOL_exists_stat = 233,              /* exists_stat  */
  YYSYMBOL_comp_stat = 234,                /* comp_stat  */
  YYSYMBOL_function_stat = 235,            /* function_stat  */
  YYSYMBOL_extract_stat = 236,             /* extract_stat  */
  YYSYMBOL_datetime_field = 237,           /* datetime_field  */
  YYSYMBOL_array_stat = 238,               /* array_stat  */
  YYSYMBOL_array_index = 239,              /* array_index  */
  YYSYMBOL_between_stat = 240,             /* between_stat  */
  YYSYMBOL_column_name = 241,              /* column_name  */
  YYSYMBOL_literal = 242,                  /* literal  */
  YYSYMBOL_string_literal = 243,           /* string_literal  */
  YYSYMBOL_bool_literal = 244,             /* bool_literal  */
  YYSYMBOL_num_literal = 245,              /* num_literal  */
  YYSYMBOL_int_literal = 246,              /* int_literal  */
  YYSYMBOL_null_literal = 247,             /* null_literal  */
  YYSYMBOL_param_stat = 248,               /* param_stat  */
  YYSYMBOL_table_ref = 249,                /* table_ref  */
  YYSYMBOL_table_ref_atomic = 250,         /* table_ref_atomic  */
  YYSYMBOL_nonjoin_table_ref_atomic = 251, /* nonjoin_table_ref_atomic  */
  YYSYMBOL_table_ref_commalist = 252,      /* table_ref_commalist  */
  YYSYMBOL_table_ref_name = 253,           /* table_ref_name  */
  YYSYMBOL_table_ref_name_no_alias = 254,  /* table_ref_name_no_alias  */
  YYSYMBOL_table_name = 255,               /* table_name  */
  YYSYMBOL_table_alias = 256,              /* table_alias  */
  YYSYMBOL_opt_table_alias = 257,          /* opt_table_alias  */
  YYSYMBOL_alias = 258,                    /* alias  */
  YYSYMBOL_opt_alias = 259,                /* opt_alias  */
  YYSYMBOL_join_clause = 260,              /* join_clause  */
  YYSYMBOL_opt_join_type = 261,            /* opt_join_type  */
  YYSYMBOL_join_condition = 262,           /* join_condition  */
  YYSYMBOL_ident_commalist = 263           /* ident_commalist  */
};
typedef enum yysymbol_kind_t yysymbol_kind_t;




#ifdef short
# undef short
#endif

/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
   <limits.h> and (if available) <stdint.h> are included
   so that the code can choose integer types of a good width.  */

#ifndef __PTRDIFF_MAX__
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
#  define YY_STDINT_H
# endif
#endif

/* Narrow types that promote to a signed type and that can represent a
   signed or unsigned integer of at least N bits.  In tables they can
   save space and decrease cache pressure.  Promoting to a signed type
   helps avoid bugs in integer arithmetic.  */

#ifdef __INT_LEAST8_MAX__
typedef __INT_LEAST8_TYPE__ yytype_int8;
#elif defined YY_STDINT_H
typedef int_least8_t yytype_int8;
#else
typedef signed char yytype_int8;
#endif

#ifdef __INT_LEAST16_MAX__
typedef __INT_LEAST16_TYPE__ yytype_int16;
#elif defined YY_STDINT_H
typedef int_least16_t yytype_int16;
#else
typedef short yytype_int16;
#endif

#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
       && UINT_LEAST8_MAX <= INT_MAX)
typedef uint_least8_t yytype_uint8;
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
typedef unsigned char yytype_uint8;
#else
typedef short yytype_uint8;
#endif

#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
       && UINT_LEAST16_MAX <= INT_MAX)
typedef uint_least16_t yytype_uint16;
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
typedef unsigned short yytype_uint16;
#else
typedef int yytype_uint16;
#endif

#ifndef YYPTRDIFF_T
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
#  define YYPTRDIFF_T __PTRDIFF_TYPE__
#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
# elif defined PTRDIFF_MAX
#  ifndef ptrdiff_t
#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  endif
#  define YYPTRDIFF_T ptrdiff_t
#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
#  define YYPTRDIFF_T long
#  define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif

#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
#  define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
#  define YYSIZE_T size_t
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# else
#  define YYSIZE_T unsigned
# endif
#endif

#define YYSIZE_MAXIMUM                                  \
  YY_CAST (YYPTRDIFF_T,                                 \
           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
            ? YYPTRDIFF_MAXIMUM                         \
            : YY_CAST (YYSIZE_T, -1)))

#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))


/* Stored state numbers (used for stacks). */
typedef yytype_int16 yy_state_t;

/* State numbers in computations.  */
typedef int yy_state_fast_t;

#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
#  if ENABLE_NLS
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
#  endif
# endif
# ifndef YY_
#  define YY_(Msgid) Msgid
# endif
#endif


#ifndef YY_ATTRIBUTE_PURE
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
#  define YY_ATTRIBUTE_PURE
# endif
#endif

#ifndef YY_ATTRIBUTE_UNUSED
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# else
#  define YY_ATTRIBUTE_UNUSED
# endif
#endif

/* Suppress unused-variable warnings by "using" E.  */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif

#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
    _Pragma ("GCC diagnostic push")                                     \
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
    _Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif

#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN                          \
    _Pragma ("GCC diagnostic push")                            \
    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END            \
    _Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif


#define YY_ASSERT(E) ((void) (0 && (E)))

#if 1

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's 'empty if-body' warning.  */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
#  ifndef YYSTACK_ALLOC_MAXIMUM
    /* The OS might guarantee only one guard page at the bottom of the stack,
       and a page size can be as small as 4096 bytes.  So we cannot safely
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
       to allow for a few compiler-allocated temporary stack slots.  */
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
#  endif
# else
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
#  ifndef YYSTACK_ALLOC_MAXIMUM
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
#  endif
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
       && ! ((defined YYMALLOC || defined malloc) \
             && (defined YYFREE || defined free)))
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   ifndef EXIT_SUCCESS
#    define EXIT_SUCCESS 0
#   endif
#  endif
#  ifndef YYMALLOC
#   define YYMALLOC malloc
#   if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
#  ifndef YYFREE
#   define YYFREE free
#   if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
#   endif
#  endif
# endif
# define YYCOPY_NEEDED 1
#endif /* 1 */

#if (! defined yyoverflow \
     && (! defined __cplusplus \
         || (defined MENT_LTYPE_IS_TRIVIAL && MENT_LTYPE_IS_TRIVIAL \
             && defined MENT_STYPE_IS_TRIVIAL && MENT_STYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  yy_state_t yyss_alloc;
  YYSTYPE yyvs_alloc;
  YYLTYPE yyls_alloc;
};

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
             + YYSIZEOF (YYLTYPE)) \
      + 2 * YYSTACK_GAP_MAXIMUM)

# define YYCOPY_NEEDED 1

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
    do                                                                  \
      {                                                                 \
        YYPTRDIFF_T yynewbytes;                                         \
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
        Stack = &yyptr->Stack_alloc;                                    \
        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
      }                                                                 \
    while (0)

#endif

#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined __GNUC__ && 1 < __GNUC__
#   define YYCOPY(Dst, Src, Count) \
      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
#  else
#   define YYCOPY(Dst, Src, Count)              \
      do                                        \
        {                                       \
          YYPTRDIFF_T yyi;                      \
          for (yyi = 0; yyi < (Count); yyi++)   \
            (Dst)[yyi] = (Src)[yyi];            \
        }                                       \
      while (0)
#  endif
# endif
#endif /* !YYCOPY_NEEDED */

/* YYFINAL -- State number of the termination state.  */
#define YYFINAL  59
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   695

/* YYNTOKENS -- Number of terminals.  */
#define YYNTOKENS  168
/* YYNNTS -- Number of nonterminals.  */
#define YYNNTS  96
/* YYNRULES -- Number of rules.  */
#define YYNRULES  247
/* YYNSTATES -- Number of states.  */
#define YYNSTATES  447

/* YYMAXUTOK -- Last valid token kind.  */
#define YYMAXUTOK   405


/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex, with out-of-bounds checking.  */
#define YYTRANSLATE(YYX)                                \
  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
   : YYSYMBOL_YYUNDEF)

/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
   as returned by yylex.  */
static const yytype_uint8 yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,   157,     2,     2,
     162,   163,   155,   153,   166,   154,   164,   156,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,   165,
     146,   143,   147,   167,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,   160,     2,   161,   158,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
      55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
      65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
      75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
      85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
      95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
     105,   106,   107,   108,   109,   110,   111,   112,   113,   114,
     115,   116,   117,   118,   119,   120,   121,   122,   123,   124,
     125,   126,   127,   128,   129,   130,   131,   132,   133,   134,
     135,   136,   137,   138,   139,   140,   141,   142,   144,   145,
     148,   149,   150,   151,   152,   159
};

#if MENT_DEBUG
  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
static const yytype_int16 yyrline[] =
{
       0,   327,   327,   328,   345,   362,   371,   377,   386,   390,
     394,   397,   404,   405,   406,   407,   408,   409,   410,   411,
     412,   421,   422,   427,   428,   432,   436,   448,   455,   458,
     462,   474,   483,   487,   497,   500,   505,   516,   527,   534,
     541,   549,   553,   562,   563,   567,   568,   572,   579,   580,
     581,   582,   583,   584,   585,   586,   587,   591,   592,   593,
     597,   601,   605,   618,   624,   630,   638,   639,   648,   673,
     686,   717,   751,   752,   762,   788,   789,   793,   809,   815,
     821,   842,   843,   847,   848,   852,   866,   887,   891,   892,
     893,   897,   898,   902,   920,   921,   925,   929,   930,   933,
     938,   939,   943,   948,   952,   953,   956,   957,   961,   962,
     966,   970,   971,   972,   978,   979,   983,   984,   985,   986,
     987,   988,   989,   990,   997,   998,  1002,  1017,  1034,  1044,
    1045,  1046,  1047,  1048,  1052,  1053,  1054,  1055,  1056,  1057,
    1058,  1059,  1060,  1061,  1065,  1066,  1070,  1071,  1072,  1073,
    1074,  1078,  1079,  1080,  1081,  1082,  1083,  1084,  1085,  1086,
    1087,  1088,  1092,  1093,  1097,  1098,  1099,  1100,  1106,  1107,
    1108,  1109,  1113,  1114,  1118,  1119,  1123,  1124,  1125,  1126,
    1127,  1128,  1129,  1133,  1134,  1138,  1142,  1143,  1144,  1145,
    1146,  1147,  1150,  1154,  1158,  1162,  1164,  1170,  1172,  1180,
    1181,  1182,  1183,  1184,  1188,  1192,  1193,  1197,  1198,  1202,
    1206,  1210,  1222,  1223,  1233,  1234,  1238,  1239,  1248,  1249,
    1254,  1265,  1274,  1275,  1280,  1281,  1286,  1287,  1291,  1292,
    1297,  1298,  1306,  1314,  1324,  1343,  1344,  1345,  1346,  1347,
    1348,  1349,  1350,  1351,  1352,  1357,  1368,  1377
};
#endif

/** Accessing symbol of state STATE.  */
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])

#if 1
/* The user-facing name of the symbol whose (internal) number is
   YYSYMBOL.  No bounds checking.  */
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;

/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
static const char *const yytname[] =
{
  "\"end of file\"", "error", "\"invalid token\"", "IDENTIFIER", "STRING",
  "FLOATVAL", "INTVAL", "SQL_ILLEGAL", "BOOL", "PRIMARY_KEY", "DEALLOCATE",
  "PARAMETERS", "INTERSECT", "TEMPORARY", "TIMESTAMP", "DISTINCT",
  "NVARCHAR", "RESTRICT", "TRUNCATE", "ANALYZE", "BETWEEN", "CASCADE",
  "COLUMNS", "CONTROL", "DEFAULT", "EXECUTE", "EXPLAIN", "HISTORY",
  "INTEGER", "NATURAL", "PREPARE", "PRIMARY", "SCHEMAS", "SPATIAL",
  "VARCHAR", "VIRTUAL", "BEFORE", "COLUMN", "CREATE", "DELETE", "DIRECT",
  "DOUBLE", "ESCAPE", "EXCEPT", "EXISTS", "EXTRACT", "GLOBAL", "HAVING",
  "IMPORT", "INSERT", "ISNULL", "OFFSET", "RENAME", "SCHEMA", "SELECT",
  "SORTED", "TABLES", "UNIQUE", "UNLOAD", "UPDATE", "VALUES", "AFTER",
  "ALTER", "CROSS", "DELTA", "FLOAT", "GROUP", "INDEX", "INNER", "LIMIT",
  "LOCAL", "MERGE", "MINUS", "ORDER", "OUTER", "RIGHT", "TABLE", "UNION",
  "USING", "WHERE", "CALL", "CASE", "CHAR", "DATE", "DESC", "DROP", "ELSE",
  "FILE", "FROM", "FULL", "HASH", "HINT", "INTO", "JOIN", "LEFT", "LIKE",
  "LOAD", "LONG", "NULL", "PLAN", "SHOW", "TEXT", "THEN", "TIME", "VIEW",
  "WHEN", "WITH", "ADD", "ALL", "AND", "ASC", "CSV", "END", "FOR", "INT",
  "KEY", "NOT", "OFF", "SET", "TBL", "TOP", "AS", "BY", "IF", "IN", "IS",
  "OF", "ON", "OR", "TO", "ARRAY", "CONCAT", "ILIKE", "SECOND", "MINUTE",
  "HOUR", "DAY", "MONTH", "YEAR", "TRUE", "FALSE", "DATABASES", "USE",
  "'='", "EQUALS", "NOTEQUALS", "'<'", "'>'", "LESS", "GREATER", "LESSEQ",
  "GREATEREQ", "NOTNULL", "'+'", "'-'", "'*'", "'/'", "'%'", "'^'",
  "UMINUS", "'['", "']'", "'('", "')'", "'.'", "';'", "','", "'?'",
  "$accept", "input", "statement_list", "statement",
  "preparable_statement", "opt_hints", "hint_list", "hint",
  "prepare_statement", "prepare_target_query", "execute_statement",
  "import_statement", "import_file_type", "file_path", "show_statement",
  "use_statement", "create_statement", "opt_not_exists",
  "column_def_commalist", "column_def", "column_type",
  "opt_column_nullable", "opt_primary_key", "drop_statement", "opt_exists",
  "delete_statement", "truncate_statement", "insert_statement",
  "opt_column_list", "update_statement", "update_clause_commalist",
  "update_clause", "select_statement", "select_with_paren",
  "select_paren_or_clause", "select_no_paren", "set_operator", "set_type",
  "opt_all", "select_clause", "opt_distinct", "select_list",
  "opt_from_clause", "from_clause", "opt_where", "opt_group", "opt_having",
  "opt_order", "order_list", "order_desc", "opt_order_type", "opt_top",
  "opt_limit", "stat_list", "literal_list", "stat_alias", "stat",
  "operand", "scalar_stat", "unary_stat", "binary_stat", "logic_stat",
  "in_stat", "case_stat", "case_list", "exists_stat", "comp_stat",
  "function_stat", "extract_stat", "datetime_field", "array_stat",
  "array_index", "between_stat", "column_name", "literal",
  "string_literal", "bool_literal", "num_literal", "int_literal",
  "null_literal", "param_stat", "table_ref", "table_ref_atomic",
  "nonjoin_table_ref_atomic", "table_ref_commalist", "table_ref_name",
  "table_ref_name_no_alias", "table_name", "table_alias",
  "opt_table_alias", "alias", "opt_alias", "join_clause", "opt_join_type",
  "join_condition", "ident_commalist", YY_NULLPTR
};

static const char *
yysymbol_name (yysymbol_kind_t yysymbol)
{
  return yytname[yysymbol];
}
#endif

#ifdef YYPRINT
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
   (internal) symbol number NUM (which must be that of a token).  */
static const yytype_int16 yytoknum[] =
{
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
     305,   306,   307,   308,   309,   310,   311,   312,   313,   314,
     315,   316,   317,   318,   319,   320,   321,   322,   323,   324,
     325,   326,   327,   328,   329,   330,   331,   332,   333,   334,
     335,   336,   337,   338,   339,   340,   341,   342,   343,   344,
     345,   346,   347,   348,   349,   350,   351,   352,   353,   354,
     355,   356,   357,   358,   359,   360,   361,   362,   363,   364,
     365,   366,   367,   368,   369,   370,   371,   372,   373,   374,
     375,   376,   377,   378,   379,   380,   381,   382,   383,   384,
     385,   386,   387,   388,   389,   390,   391,   392,   393,   394,
     395,   396,   397,    61,   398,   399,    60,    62,   400,   401,
     402,   403,   404,    43,    45,    42,    47,    37,    94,   405,
      91,    93,    40,    41,    46,    59,    44,    63
};
#endif

#define YYPACT_NINF (-340)

#define yypact_value_is_default(Yyn) \
  ((Yyn) == YYPACT_NINF)

#define YYTABLE_NINF (-245)

#define yytable_value_is_error(Yyn) \
  ((Yyn) == YYTABLE_NINF)

  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
     STATE-NUM.  */
static const yytype_int16 yypact[] =
{
     368,  -340,    29,    48,    64,    87,   -34,     6,    14,    19,
     -17,    48,    -8,    21,    48,   -36,   104,   -29,  -340,    25,
      25,  -340,  -340,  -340,  -340,  -340,  -340,  -340,  -340,  -340,
    -340,  -340,    12,  -340,     9,   161,    26,  -340,    63,    82,
      48,   103,   108,   108,    48,   126,    48,   233,   234,   130,
    -340,   134,   134,    48,  -340,  -340,  -340,    95,   105,  -340,
     385,   182,  -340,  -340,  -340,  -340,  -340,   -36,   168,   155,
     -36,    46,  -340,   279,    32,   282,  -340,    48,   184,    48,
      48,   222,  -340,   217,   147,  -340,  -340,  -340,   183,   307,
     268,    48,    48,  -340,  -340,  -340,  -340,   152,  -340,   242,
    -340,  -340,  -340,   183,   242,   233,    16,  -340,  -340,  -340,
    -340,  -340,  -340,  -340,  -340,   -23,  -340,  -340,  -340,  -340,
    -340,  -340,  -340,  -340,  -340,   154,   275,   -74,   147,   183,
    -340,   316,   318,    45,  -136,   162,   164,   116,   230,   167,
     302,  -340,   163,   241,   165,  -340,     4,   351,  -340,  -340,
    -340,  -340,  -340,  -340,  -340,  -340,  -340,  -340,  -340,  -340,
    -340,  -340,  -340,   189,   -66,  -340,  -340,  -340,  -340,   331,
      46,   170,  -340,   -53,    46,  -340,   297,   298,   300,  -340,
      32,    48,  -340,   235,   349,   232,    67,   263,  -340,  -340,
      28,   194,  -340,    10,     7,   304,   206,   183,    70,    30,
     197,   302,   467,   183,    85,   198,   -89,     3,   222,  -340,
     183,  -340,   183,   359,   183,  -340,  -340,   302,  -340,   302,
     -51,   202,    86,   302,   302,   302,   302,   302,   302,   302,
     302,   302,   302,   302,   302,   302,   302,   302,   233,   183,
     307,  -340,   203,    38,  -340,  -340,   183,  -340,  -340,  -340,
    -340,   233,   233,   233,  -340,   204,   281,   421,    52,  -340,
     -36,    48,  -340,   363,    32,  -340,   183,  -340,  -340,   209,
    -340,  -340,  -340,  -340,  -340,  -340,   285,   -11,    88,   183,
     183,  -340,   304,   284,   -60,  -340,  -340,   -36,  -340,   191,
    -340,   208,  -340,    13,  -340,   310,  -340,  -340,  -340,   271,
     424,   501,   302,   215,   163,  -340,   283,   228,   501,   501,
     501,   501,   535,   535,   535,   535,    85,    85,   -73,   -73,
     -73,   -81,   221,    67,  -340,    32,  -340,   331,  -340,  -340,
    -340,  -340,  -340,   316,  -340,  -340,   225,  -340,  -340,   229,
    -340,  -340,  -340,   131,  -340,   349,  -340,  -340,  -340,    60,
      97,  -340,   183,   183,   183,  -340,   -63,   110,   226,  -340,
     231,   303,  -340,  -340,  -340,   325,   328,   330,   312,     3,
     387,  -340,  -340,  -340,   286,  -340,   302,   501,   163,   246,
     106,  -340,  -340,   124,  -340,  -340,   405,   406,  -340,   321,
      98,  -340,  -340,  -340,   -80,    67,    94,  -340,   183,  -340,
      13,     3,  -340,  -340,  -340,     3,   384,   252,   183,   467,
     257,   125,  -340,  -340,  -340,   258,   262,  -340,  -340,   311,
    -340,  -340,  -340,    67,  -340,  -340,   463,   318,   -38,  -340,
    -340,  -340,  -340,  -340,   266,   183,   129,   183,  -340,     8,
      67,  -340,  -340,    67,   267,   272,  -340
};

  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
     Performed when YYTABLE does not specify something else to do.  Zero
     means the default is an error.  */
static const yytype_uint8 yydefact[] =
{
       2,     5,     0,     0,     0,     0,     0,     0,     0,     0,
     115,     0,     0,     0,     0,     0,     0,     4,     6,    22,
      22,    20,    13,    10,    11,    14,    19,    16,    17,    15,
      18,    12,    78,    79,   107,     0,   222,    69,    29,     0,
       0,     0,    44,    44,     0,     0,     0,     0,    95,     0,
     221,    67,    67,     0,    36,    34,    37,     0,     0,     1,
       3,     0,     9,     8,    89,    90,    88,     0,    92,     0,
       0,   123,    65,     0,     0,     0,    41,     0,     0,     0,
       0,   101,    32,     0,    73,   209,   114,    94,     0,     0,
       0,     0,     0,    35,    82,    81,     7,     0,    83,   107,
      84,    91,    87,     0,   107,     0,     0,    85,   223,   204,
     207,   210,   205,   206,   211,     0,   126,   199,   200,   201,
     208,   202,   203,    28,    27,     0,     0,     0,    73,     0,
      68,     0,     0,     0,   195,     0,     0,     0,     0,     0,
       0,   197,     0,    98,    96,   124,   231,   129,   136,   137,
     138,   131,   133,   139,   132,   151,   140,   141,   142,   135,
     130,   144,   145,     0,   101,    75,    66,    63,    64,     0,
     123,   106,   108,   113,   123,   118,   120,   119,   116,    30,
       0,     0,    43,     0,     0,     0,   100,     0,    33,   246,
       0,     0,    71,    95,     0,     0,     0,     0,     0,     0,
       0,     0,   147,     0,   146,     0,     0,     0,   101,    97,
       0,   229,     0,     0,     0,   230,   128,     0,   148,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    74,    25,     0,    23,    80,     0,   112,   111,   110,
      86,     0,     0,     0,   127,     0,     0,     0,     0,    45,
       0,     0,    72,     0,     0,   183,     0,   196,   198,     0,
     186,   187,   188,   189,   190,   191,     0,     0,     0,     0,
       0,   170,     0,     0,     0,   143,   134,     0,    99,   212,
     214,     0,   216,   227,   215,   103,   125,   162,   228,   163,
       0,   158,     0,     0,     0,   149,     0,   161,   160,   176,
     177,   178,   179,   180,   181,   182,   153,   152,   155,   154,
     156,   157,     0,    77,    76,     0,    21,     0,   109,   122,
     121,   117,    42,     0,    56,    49,     0,    52,    51,     0,
      50,    55,    48,    59,    39,     0,    40,    31,   247,     0,
       0,   174,     0,     0,     0,   168,     0,     0,     0,   192,
       0,     0,   243,   235,   241,   239,   242,   237,     0,     0,
       0,   226,   220,   224,     0,    93,     0,   159,     0,     0,
       0,   150,   193,     0,    24,    38,     0,     0,    57,     0,
      60,    46,    70,   184,     0,   172,     0,   171,     0,   175,
     227,     0,   238,   240,   236,     0,   213,   228,     0,   194,
       0,     0,   166,   164,    26,     0,     0,    58,    61,     0,
      47,   185,   169,   173,   217,   232,   244,     0,   105,   167,
     165,    53,    54,    62,     0,     0,     0,     0,   102,     0,
     245,   233,   225,   104,   195,     0,   234
};

  /* YYPGOTO[NTERM-NUM].  */
static const yytype_int16 yypgoto[] =
{
    -340,  -340,  -340,   370,  -340,   416,  -340,   111,  -340,  -340,
    -340,  -340,  -340,   107,  -340,  -340,  -340,   394,  -340,   100,
    -340,  -340,  -340,  -340,   391,  -340,  -340,  -340,   320,  -340,
    -340,   210,  -226,     2,   381,   -15,   420,  -340,  -340,   227,
     270,  -340,  -340,  -340,  -132,  -340,  -340,    34,  -340,   214,
    -340,  -340,    11,  -195,  -241,   251,  -102,   -78,  -340,  -340,
    -340,  -340,  -340,  -340,   273,  -340,  -340,  -340,  -340,  -340,
    -340,  -340,  -340,    27,   -72,  -128,  -340,  -340,   -42,  -340,
    -340,  -340,  -339,    71,  -340,  -340,  -340,     1,  -340,    65,
     333,  -340,  -340,  -340,  -340,    53
};

  /* YYDEFGOTO[NTERM-NUM].  */
static const yytype_int16 yydefgoto[] =
{
      -1,    16,    17,    18,    19,    62,   243,   244,    20,   124,
      21,    22,    83,   187,    23,    24,    25,    79,   258,   259,
     343,   390,   420,    26,    91,    27,    28,    29,   133,    30,
     164,   165,    31,    32,    99,    33,    67,    68,   102,    34,
      88,   143,   208,   209,   130,   375,   438,    71,   171,   172,
     249,    48,   107,   144,   115,   145,   146,   147,   148,   149,
     150,   151,   152,   153,   199,   154,   155,   156,   157,   276,
     158,   159,   160,   161,   162,   117,   118,   119,   120,   121,
     122,   288,   289,   290,   291,   292,    49,   293,   371,   372,
     373,   216,   294,   368,   441,   190
};

  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
     positive, shift that token.  If negative, reduce the rule whose
     number is the opposite.  If YYTABLE_NINF, syntax error.  */
static const yytype_int16 yytable[] =
{
      58,   173,   116,   188,    37,    86,    36,   211,   284,   437,
     267,   444,    50,   129,   183,    56,   211,    57,    10,    40,
     212,    64,    85,   349,    64,    87,   193,   186,   194,   212,
     406,   247,   241,    41,   346,   198,   109,   110,    85,   214,
     206,    76,    42,    53,   302,    81,   212,    84,   214,   397,
     223,    36,    65,    54,    93,    65,   212,   248,   223,    35,
     202,   360,   204,   175,   178,   214,   426,    38,    51,    98,
      43,   350,    98,   303,   286,   214,   295,    55,   125,   238,
     127,   128,    69,   421,   383,   237,    66,   238,   184,    66,
      39,   353,   167,   168,    44,   277,    52,   105,   212,    10,
     240,   359,    45,    47,    59,   191,   210,   418,   254,   380,
     297,    46,   299,   212,   176,   106,   279,   214,   192,   134,
     109,   110,    85,   202,   177,   213,    15,   205,   210,   419,
     111,    61,   214,   170,   370,   280,    60,   323,   174,   300,
     179,   301,   281,   180,   173,   307,   308,   309,   310,   311,
     312,   313,   314,   315,   316,   317,   318,   319,   320,   321,
     135,   136,   268,   141,    72,   287,   134,   109,   110,    85,
      75,   112,   113,   265,   354,   197,   212,   356,   357,   212,
     269,   245,   255,   411,   305,   250,   134,   109,   110,    85,
      73,   262,   116,   280,   263,   214,   322,   137,   214,   114,
     355,   326,   306,   212,   327,   188,   422,   135,   136,   329,
     330,   331,   398,   428,   111,   344,   223,    10,   345,   212,
     361,   197,   214,   392,   377,    74,   180,   135,   136,   388,
      77,    78,   138,   134,   109,   110,    85,    82,   214,    85,
     234,   235,   236,   237,   137,   238,   139,   389,    89,    87,
     394,   395,   396,   116,   362,   112,   113,    90,    94,   363,
     393,   111,   347,   210,   137,   364,   365,   358,    95,   413,
     140,   141,   210,    97,   200,   136,   101,   103,   142,   138,
     366,   111,   108,   114,  -244,   367,   123,   414,   430,   379,
     180,   210,   442,   139,   100,   263,   423,   100,   409,   138,
     126,   129,   112,   113,   131,   134,   109,   110,    85,   132,
     163,   137,   166,   139,   169,    69,   181,   140,   141,   182,
     109,   189,   112,   113,   195,   142,   196,   203,   111,   207,
     114,   210,   239,   440,   242,   443,   246,   140,   141,   270,
     271,   272,   273,   274,   275,   142,   201,   136,   251,   252,
     114,   253,   257,   260,   256,   261,   264,  -218,    10,   282,
     139,   285,   298,   410,   304,   325,   348,   332,   333,   112,
     113,   217,   351,   352,   369,     1,   374,   378,     2,   302,
     212,   381,   382,   137,   140,   141,     3,   386,   238,   399,
     407,   387,   142,     4,   400,     2,   401,   114,     5,   402,
     111,   218,   403,     3,   404,   405,     6,     7,   408,   412,
       4,   415,   416,   361,   427,     5,     8,     9,   201,   417,
     429,   431,    10,     6,     7,   432,   433,    11,   439,   334,
      96,   194,   139,     8,     9,   446,    63,    80,   384,    10,
     385,   112,   113,    92,    11,   391,   219,   362,   185,   335,
     324,   104,   363,    12,    70,   336,   140,   141,   364,   365,
     328,   296,   337,   266,   142,   424,   445,   220,    13,   114,
      12,   278,   425,   366,   218,   221,   222,  -244,   367,   215,
     436,     0,   223,   224,     0,    13,   338,     0,     0,     0,
       0,     0,   361,     0,   225,   226,   227,   228,   229,     0,
       0,   230,   231,   339,   232,   233,   234,   235,   236,   237,
      14,   238,     0,     0,     0,     0,     0,   218,   340,   219,
       0,     0,   341,     0,     0,     0,   362,    14,     0,     0,
      15,   363,     0,   376,     0,   342,     0,   364,   365,     0,
     283,   434,     0,     0,     0,     0,     0,    15,     0,   222,
    -219,   218,   366,     0,     0,   223,   224,   367,     0,     0,
       0,     0,   219,     0,     0,     0,     0,   225,   226,   227,
     228,   229,     0,     0,   230,   231,     0,   232,   233,   234,
     235,   236,   237,   283,   238,   218,     0,     0,     0,     0,
     435,     0,   222,     0,     0,     0,  -245,     0,   223,   224,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
     225,   226,   227,   228,   229,     0,     0,   230,   231,     0,
     232,   233,   234,   235,   236,   237,   222,   238,     0,     0,
       0,     0,   223,  -245,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,  -245,  -245,  -245,   228,   229,     0,
       0,   230,   231,     0,   232,   233,   234,   235,   236,   237,
     222,   238,     0,     0,     0,     0,   223,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,  -245,  -245,     0,     0,  -245,  -245,     0,   232,   233,
     234,   235,   236,   237,     0,   238
};

static const yytype_int16 yycheck[] =
{
      15,   103,    74,   131,     3,    47,     3,     3,   203,    47,
       3,     3,    11,    79,    88,    14,     3,    15,    54,    53,
     109,    12,     6,   264,    12,    15,   162,   129,   164,   109,
     369,    84,   164,    67,   260,   137,     4,     5,     6,   128,
     142,    40,    76,    22,    95,    44,   109,    46,   128,   112,
     131,     3,    43,    32,    53,    43,   109,   110,   131,    30,
     138,   287,   140,   105,   106,   128,   405,     3,    76,    67,
     104,   266,    70,   124,   163,   128,   208,    56,    77,   160,
      79,    80,    73,   163,   325,   158,    77,   160,   162,    77,
       3,   102,    91,    92,    88,   197,   104,    51,   109,    54,
     166,   161,    88,   120,     0,    60,   166,     9,   180,   304,
     212,    92,   214,   109,    98,    69,    86,   128,   133,     3,
       4,     5,     6,   201,   108,   121,   162,   142,   166,    31,
      98,   106,   128,    99,   121,   105,   165,   239,   104,   217,
     163,   219,   112,   166,   246,   223,   224,   225,   226,   227,
     228,   229,   230,   231,   232,   233,   234,   235,   236,   237,
      44,    45,   155,   155,     3,   162,     3,     4,     5,     6,
      88,   139,   140,   163,    86,   105,   109,   279,   280,   109,
     195,   170,   181,   378,    98,   174,     3,     4,     5,     6,
     164,   163,   264,   105,   166,   128,   238,    81,   128,   167,
     112,   163,   116,   109,   166,   333,   112,    44,    45,   251,
     252,   253,   102,   408,    98,   163,   131,    54,   166,   109,
      29,   105,   128,   163,   302,   162,   166,    44,    45,    98,
     127,   123,   116,     3,     4,     5,     6,   111,   128,     6,
     155,   156,   157,   158,    81,   160,   130,   116,   118,    15,
     352,   353,   354,   325,    63,   139,   140,   123,   163,    68,
     163,    98,   261,   166,    81,    74,    75,   282,   163,   163,
     154,   155,   166,    91,    44,    45,   108,   122,   162,   116,
      89,    98,     3,   167,    93,    94,     4,   163,   163,   304,
     166,   166,   163,   130,    67,   166,   398,    70,   376,   116,
     116,    79,   139,   140,    87,     3,     4,     5,     6,   162,
       3,    81,    44,   130,   162,    73,   162,   154,   155,    44,
       4,     3,   139,   140,   162,   162,   162,   160,    98,    88,
     167,   166,   143,   435,     3,   437,   166,   154,   155,   133,
     134,   135,   136,   137,   138,   162,   116,    45,    51,    51,
     167,    51,     3,   121,   119,    92,   162,   166,    54,   162,
     130,   163,     3,   378,   162,   162,     3,   163,    87,   139,
     140,    20,   163,    88,   166,     7,    66,   162,    10,    95,
     109,    98,   161,    81,   154,   155,    18,   162,   160,   163,
       3,   162,   162,    25,   163,    10,    93,   167,    30,    74,
      98,    50,    74,    18,    74,    93,    38,    39,   122,   163,
      25,     6,     6,    29,   162,    30,    48,    49,   116,    98,
     163,   163,    54,    38,    39,   163,   115,    59,   162,     8,
      60,   164,   130,    48,    49,   163,    20,    43,   327,    54,
     333,   139,   140,    52,    59,   345,    95,    63,   128,    28,
     240,    70,    68,    85,    34,    34,   154,   155,    74,    75,
     246,   210,    41,   193,   162,   400,   439,   116,   100,   167,
      85,   198,   401,    89,    50,   124,   125,    93,    94,   146,
     427,    -1,   131,   132,    -1,   100,    65,    -1,    -1,    -1,
      -1,    -1,    29,    -1,   143,   144,   145,   146,   147,    -1,
      -1,   150,   151,    82,   153,   154,   155,   156,   157,   158,
     142,   160,    -1,    -1,    -1,    -1,    -1,    50,    97,    95,
      -1,    -1,   101,    -1,    -1,    -1,    63,   142,    -1,    -1,
     162,    68,    -1,   109,    -1,   114,    -1,    74,    75,    -1,
     116,    78,    -1,    -1,    -1,    -1,    -1,   162,    -1,   125,
     166,    50,    89,    -1,    -1,   131,   132,    94,    -1,    -1,
      -1,    -1,    95,    -1,    -1,    -1,    -1,   143,   144,   145,
     146,   147,    -1,    -1,   150,   151,    -1,   153,   154,   155,
     156,   157,   158,   116,   160,    50,    -1,    -1,    -1,    -1,
     127,    -1,   125,    -1,    -1,    -1,    95,    -1,   131,   132,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
     143,   144,   145,   146,   147,    -1,    -1,   150,   151,    -1,
     153,   154,   155,   156,   157,   158,   125,   160,    -1,    -1,
      -1,    -1,   131,   132,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,   143,   144,   145,   146,   147,    -1,
      -1,   150,   151,    -1,   153,   154,   155,   156,   157,   158,
     125,   160,    -1,    -1,    -1,    -1,   131,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,   146,   147,    -1,    -1,   150,   151,    -1,   153,   154,
     155,   156,   157,   158,    -1,   160
};

  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
     symbol of state STATE-NUM.  */
static const yytype_int16 yystos[] =
{
       0,     7,    10,    18,    25,    30,    38,    39,    48,    49,
      54,    59,    85,   100,   142,   162,   169,   170,   171,   172,
     176,   178,   179,   182,   183,   184,   191,   193,   194,   195,
     197,   200,   201,   203,   207,    30,     3,   255,     3,     3,
      53,    67,    76,   104,    88,    88,    92,   120,   219,   254,
     255,    76,   104,    22,    32,    56,   255,   201,   203,     0,
     165,   106,   173,   173,    12,    43,    77,   204,   205,    73,
     204,   215,     3,   164,   162,    88,   255,   127,   123,   185,
     185,   255,   111,   180,   255,     6,   246,    15,   208,   118,
     123,   192,   192,   255,   163,   163,   171,    91,   201,   202,
     207,   108,   206,   122,   202,    51,    69,   220,     3,     4,
       5,    98,   139,   140,   167,   222,   242,   243,   244,   245,
     246,   247,   248,     4,   177,   255,   116,   255,   255,    79,
     212,    87,   162,   196,     3,    44,    45,    81,   116,   130,
     154,   155,   162,   209,   221,   223,   224,   225,   226,   227,
     228,   229,   230,   231,   233,   234,   235,   236,   238,   239,
     240,   241,   242,     3,   198,   199,    44,   255,   255,   162,
     215,   216,   217,   224,   215,   246,    98,   108,   246,   163,
     166,   162,    44,    88,   162,   196,   224,   181,   243,     3,
     263,    60,   203,   162,   164,   162,   162,   105,   224,   232,
      44,   116,   225,   160,   225,   203,   224,    88,   210,   211,
     166,     3,   109,   121,   128,   258,   259,    20,    50,    95,
     116,   124,   125,   131,   132,   143,   144,   145,   146,   147,
     150,   151,   153,   154,   155,   156,   157,   158,   160,   143,
     166,   212,     3,   174,   175,   220,   166,    84,   110,   218,
     220,    51,    51,    51,   242,   255,   119,     3,   186,   187,
     121,    92,   163,   166,   162,   163,   208,     3,   155,   203,
     133,   134,   135,   136,   137,   138,   237,   224,   232,    86,
     105,   112,   162,   116,   221,   163,   163,   162,   249,   250,
     251,   252,   253,   255,   260,   212,   223,   224,     3,   224,
     225,   225,    95,   124,   162,    98,   116,   225,   225,   225,
     225,   225,   225,   225,   225,   225,   225,   225,   225,   225,
     225,   225,   246,   224,   199,   162,   163,   166,   217,   246,
     246,   246,   163,    87,     8,    28,    34,    41,    65,    82,
      97,   101,   114,   188,   163,   166,   200,   255,     3,   222,
     221,   163,    88,   102,    86,   112,   224,   224,   203,   161,
     200,    29,    63,    68,    74,    75,    89,    94,   261,   166,
     121,   256,   257,   258,    66,   213,   109,   225,   162,   203,
     221,    98,   161,   222,   175,   181,   162,   162,    98,   116,
     189,   187,   163,   163,   224,   224,   224,   112,   102,   163,
     163,    93,    74,    74,    74,    93,   250,     3,   122,   225,
     203,   221,   163,   163,   163,     6,     6,    98,     9,    31,
     190,   163,   112,   224,   257,   251,   250,   162,   221,   163,
     163,   163,   163,   115,    78,   127,   263,    47,   214,   162,
     224,   262,   163,   224,     3,   241,   163
};

  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const yytype_int16 yyr1[] =
{
       0,   168,   169,   169,   169,   169,   170,   170,   171,   171,
     171,   171,   172,   172,   172,   172,   172,   172,   172,   172,
     172,   173,   173,   174,   174,   175,   175,   176,   177,   178,
     178,   179,   180,   181,   182,   182,   182,   183,   184,   184,
     184,   184,   184,   185,   185,   186,   186,   187,   188,   188,
     188,   188,   188,   188,   188,   188,   188,   189,   189,   189,
     190,   190,   190,   191,   191,   191,   192,   192,   193,   194,
     195,   195,   196,   196,   197,   198,   198,   199,   200,   200,
     200,   201,   201,   202,   202,   203,   203,   204,   205,   205,
     205,   206,   206,   207,   208,   208,   209,   210,   210,   211,
     212,   212,   213,   213,   214,   214,   215,   215,   216,   216,
     217,   218,   218,   218,   219,   219,   220,   220,   220,   220,
     220,   220,   220,   220,   221,   221,   222,   222,   223,   224,
     224,   224,   224,   224,   225,   225,   225,   225,   225,   225,
     225,   225,   225,   225,   226,   226,   227,   227,   227,   227,
     227,   228,   228,   228,   228,   228,   228,   228,   228,   228,
     228,   228,   229,   229,   230,   230,   230,   230,   231,   231,
     231,   231,   232,   232,   233,   233,   234,   234,   234,   234,
     234,   234,   234,   235,   235,   236,   237,   237,   237,   237,
     237,   237,   238,   239,   240,   241,   241,   241,   241,   242,
     242,   242,   242,   242,   243,   244,   244,   245,   245,   246,
     247,   248,   249,   249,   250,   250,   251,   251,   252,   252,
     253,   254,   255,   255,   256,   256,   257,   257,   258,   258,
     259,   259,   260,   260,   260,   261,   261,   261,   261,   261,
     261,   261,   261,   261,   261,   262,   263,   263
};

  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
static const yytype_int8 yyr2[] =
{
       0,     2,     0,     2,     1,     1,     1,     3,     2,     2,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     5,     0,     1,     3,     1,     4,     4,     1,     2,
       5,     7,     1,     1,     2,     3,     2,     2,     8,     7,
       7,     3,     7,     3,     0,     1,     3,     4,     1,     1,
       1,     1,     1,     4,     4,     1,     1,     1,     2,     0,
       0,     1,     2,     4,     4,     3,     2,     0,     4,     2,
       8,     5,     3,     0,     5,     1,     3,     3,     1,     1,
       5,     3,     3,     1,     1,     3,     5,     2,     1,     1,
       1,     1,     0,     7,     1,     0,     1,     1,     0,     2,
       2,     0,     4,     0,     2,     0,     3,     0,     1,     3,
       2,     1,     1,     0,     2,     0,     2,     4,     2,     2,
       2,     4,     4,     0,     1,     3,     1,     3,     2,     1,
       1,     1,     1,     1,     3,     1,     1,     1,     1,     1,
       1,     1,     1,     3,     1,     1,     2,     2,     2,     3,
       4,     1,     3,     3,     3,     3,     3,     3,     3,     4,
       3,     3,     3,     3,     5,     6,     5,     6,     4,     6,
       3,     5,     4,     5,     4,     5,     3,     3,     3,     3,
       3,     3,     3,     3,     5,     6,     1,     1,     1,     1,
       1,     1,     4,     4,     5,     1,     3,     1,     3,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     1,     1,     3,     1,     1,     1,     4,     1,     3,
       2,     1,     1,     3,     1,     5,     1,     0,     2,     1,
       1,     0,     4,     6,     8,     1,     2,     1,     2,     1,
       2,     1,     1,     1,     0,     1,     1,     3
};


enum { YYENOMEM = -2 };

#define yyerrok         (yyerrstatus = 0)
#define yyclearin       (yychar = SQL_MENT_EMPTY)

#define YYACCEPT        goto yyacceptlab
#define YYABORT         goto yyabortlab
#define YYERROR         goto yyerrorlab


#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)                                    \
  do                                                              \
    if (yychar == SQL_MENT_EMPTY)                                        \
      {                                                           \
        yychar = (Token);                                         \
        yylval = (Value);                                         \
        YYPOPSTACK (yylen);                                       \
        yystate = *yyssp;                                         \
        YY_LAC_DISCARD ("YYBACKUP");                              \
        goto yybackup;                                            \
      }                                                           \
    else                                                          \
      {                                                           \
        yyerror (&yylloc, result, scanner, YY_("syntax error: cannot back up")); \
        YYERROR;                                                  \
      }                                                           \
  while (0)

/* Backward compatibility with an undocumented macro.
   Use SQL_MENT_error or SQL_MENT_UNDEF. */
#define YYERRCODE SQL_MENT_UNDEF

/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
   If N is 0, then set CURRENT to the empty location which ends
   the previous symbol: RHS[0] (always defined).  */

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
    do                                                                  \
      if (N)                                                            \
        {                                                               \
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
        }                                                               \
      else                                                              \
        {                                                               \
          (Current).first_line   = (Current).last_line   =              \
            YYRHSLOC (Rhs, 0).last_line;                                \
          (Current).first_column = (Current).last_column =              \
            YYRHSLOC (Rhs, 0).last_column;                              \
        }                                                               \
    while (0)
#endif

#define YYRHSLOC(Rhs, K) ((Rhs)[K])


/* Enable debugging if requested.  */
#if MENT_DEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)                        \
do {                                            \
  if (yydebug)                                  \
    YYFPRINTF Args;                             \
} while (0)


/* YY_LOCATION_PRINT -- Print the location on the stream.
   This macro was not mandated originally: define only if we know
   we won't break user code: when these are the locations we know.  */

# ifndef YY_LOCATION_PRINT
#  if defined MENT_LTYPE_IS_TRIVIAL && MENT_LTYPE_IS_TRIVIAL

/* Print *YYLOCP on YYO.  Private, do not rely on its existence. */

YY_ATTRIBUTE_UNUSED
static int
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
{
  int res = 0;
  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
  if (0 <= yylocp->first_line)
    {
      res += YYFPRINTF (yyo, "%d", yylocp->first_line);
      if (0 <= yylocp->first_column)
        res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
    }
  if (0 <= yylocp->last_line)
    {
      if (yylocp->first_line < yylocp->last_line)
        {
          res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
          if (0 <= end_col)
            res += YYFPRINTF (yyo, ".%d", end_col);
        }
      else if (0 <= end_col && yylocp->first_column < end_col)
        res += YYFPRINTF (yyo, "-%d", end_col);
    }
  return res;
 }

#   define YY_LOCATION_PRINT(File, Loc)          \
  yy_location_print_ (File, &(Loc))

#  else
#   define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#  endif
# endif /* !defined YY_LOCATION_PRINT */


# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
do {                                                                      \
  if (yydebug)                                                            \
    {                                                                     \
      YYFPRINTF (stderr, "%s ", Title);                                   \
      yy_symbol_print (stderr,                                            \
                  Kind, Value, Location, result, scanner); \
      YYFPRINTF (stderr, "\n");                                           \
    }                                                                     \
} while (0)


/*-----------------------------------.
| Print this symbol's value on YYO.  |
`-----------------------------------*/

static void
yy_symbol_value_print (FILE *yyo,
                       yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, ment::SQLParserResult* result, yyscan_t scanner)
{
  FILE *yyoutput = yyo;
  YYUSE (yyoutput);
  YYUSE (yylocationp);
  YYUSE (result);
  YYUSE (scanner);
  if (!yyvaluep)
    return;
# ifdef YYPRINT
  if (yykind < YYNTOKENS)
    YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
# endif
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  YYUSE (yykind);
  YY_IGNORE_MAYBE_UNINITIALIZED_END
}


/*---------------------------.
| Print this symbol on YYO.  |
`---------------------------*/

static void
yy_symbol_print (FILE *yyo,
                 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, ment::SQLParserResult* result, yyscan_t scanner)
{
  YYFPRINTF (yyo, "%s %s (",
             yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));

  YY_LOCATION_PRINT (yyo, *yylocationp);
  YYFPRINTF (yyo, ": ");
  yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, result, scanner);
  YYFPRINTF (yyo, ")");
}

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included).                                                   |
`------------------------------------------------------------------*/

static void
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
{
  YYFPRINTF (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      YYFPRINTF (stderr, " %d", yybot);
    }
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)                            \
do {                                                            \
  if (yydebug)                                                  \
    yy_stack_print ((Bottom), (Top));                           \
} while (0)


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

static void
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
                 int yyrule, ment::SQLParserResult* result, yyscan_t scanner)
{
  int yylno = yyrline[yyrule];
  int yynrhs = yyr2[yyrule];
  int yyi;
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
             yyrule - 1, yylno);
  /* The symbols being reduced.  */
  for (yyi = 0; yyi < yynrhs; yyi++)
    {
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
      yy_symbol_print (stderr,
                       YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
                       &yyvsp[(yyi + 1) - (yynrhs)],
                       &(yylsp[(yyi + 1) - (yynrhs)]), result, scanner);
      YYFPRINTF (stderr, "\n");
    }
}

# define YY_REDUCE_PRINT(Rule)          \
do {                                    \
  if (yydebug)                          \
    yy_reduce_print (yyssp, yyvsp, yylsp, Rule, result, scanner); \
} while (0)

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !MENT_DEBUG */
# define YYDPRINTF(Args) ((void) 0)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !MENT_DEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif


/* Given a state stack such that *YYBOTTOM is its bottom, such that
   *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
   stack, and such that *YYCAPACITY is the maximum number of elements it
   can hold without a reallocation, make sure there is enough room to
   store YYADD more elements.  If not, allocate a new stack using
   YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
   *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
   location.  If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
   using YYSTACK_FREE.  Return 0 if successful or if no reallocation is
   required.  Return YYENOMEM if memory is exhausted.  */
static int
yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
#if MENT_DEBUG
                      char const *yydebug_prefix,
                      char const *yydebug_suffix,
#endif
                      yy_state_t **yybottom,
                      yy_state_t *yybottom_no_free,
                      yy_state_t **yytop, yy_state_t *yytop_empty)
{
  YYPTRDIFF_T yysize_old =
    *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
  YYPTRDIFF_T yysize_new = yysize_old + yyadd;
  if (*yycapacity < yysize_new)
    {
      YYPTRDIFF_T yyalloc = 2 * yysize_new;
      yy_state_t *yybottom_new;
      /* Use YYMAXDEPTH for maximum stack size given that the stack
         should never need to grow larger than the main state stack
         needs to grow without LAC.  */
      if (YYMAXDEPTH < yysize_new)
        {
          YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
                      yydebug_suffix));
          return YYENOMEM;
        }
      if (YYMAXDEPTH < yyalloc)
        yyalloc = YYMAXDEPTH;
      yybottom_new =
        YY_CAST (yy_state_t *,
                 YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
                                         yyalloc * YYSIZEOF (*yybottom_new))));
      if (!yybottom_new)
        {
          YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
                      yydebug_suffix));
          return YYENOMEM;
        }
      if (*yytop != yytop_empty)
        {
          YYCOPY (yybottom_new, *yybottom, yysize_old);
          *yytop = yybottom_new + (yysize_old - 1);
        }
      if (*yybottom != yybottom_no_free)
        YYSTACK_FREE (*yybottom);
      *yybottom = yybottom_new;
      *yycapacity = yyalloc;
    }
  return 0;
}

/* Establish the initial context for the current lookahead if no initial
   context is currently established.

   We define a context as a snapshot of the parser stacks.  We define
   the initial context for a lookahead as the context in which the
   parser initially examines that lookahead in order to select a
   syntactic action.  Thus, if the lookahead eventually proves
   syntactically unacceptable (possibly in a later context reached via a
   series of reductions), the initial context can be used to determine
   the exact set of tokens that would be syntactically acceptable in the
   lookahead's place.  Moreover, it is the context after which any
   further semantic actions would be erroneous because they would be
   determined by a syntactically unacceptable token.

   YY_LAC_ESTABLISH should be invoked when a reduction is about to be
   performed in an inconsistent state (which, for the purposes of LAC,
   includes consistent states that don't know they're consistent because
   their default reductions have been disabled).  Iff there is a
   lookahead token, it should also be invoked before reporting a syntax
   error.  This latter case is for the sake of the debugging output.

   For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
   follows.  If no initial context is currently established for the
   current lookahead, then check if that lookahead can eventually be
   shifted if syntactic actions continue from the current context.
   Report a syntax error if it cannot.  */
#define YY_LAC_ESTABLISH                                                \
do {                                                                    \
  if (!yy_lac_established)                                              \
    {                                                                   \
      YYDPRINTF ((stderr,                                               \
                  "LAC: initial context established for %s\n",          \
                  yysymbol_name (yytoken)));                            \
      yy_lac_established = 1;                                           \
      switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken))    \
        {                                                               \
        case YYENOMEM:                                                  \
          goto yyexhaustedlab;                                          \
        case 1:                                                         \
          goto yyerrlab;                                                \
        }                                                               \
    }                                                                   \
} while (0)

/* Discard any previous initial lookahead context because of Event,
   which may be a lookahead change or an invalidation of the currently
   established initial context for the current lookahead.

   The most common example of a lookahead change is a shift.  An example
   of both cases is syntax error recovery.  That is, a syntax error
   occurs when the lookahead is syntactically erroneous for the
   currently established initial context, so error recovery manipulates
   the parser stacks to try to find a new initial context in which the
   current lookahead is syntactically acceptable.  If it fails to find
   such a context, it discards the lookahead.  */
#if MENT_DEBUG
# define YY_LAC_DISCARD(Event)                                           \
do {                                                                     \
  if (yy_lac_established)                                                \
    {                                                                    \
      YYDPRINTF ((stderr, "LAC: initial context discarded due to "       \
                  Event "\n"));                                          \
      yy_lac_established = 0;                                            \
    }                                                                    \
} while (0)
#else
# define YY_LAC_DISCARD(Event) yy_lac_established = 0
#endif

/* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
   eventually (after perhaps some reductions) be shifted, return 1 if
   not, or return YYENOMEM if memory is exhausted.  As preconditions and
   postconditions: *YYES_CAPACITY is the allocated size of the array to
   which *YYES points, and either *YYES = YYESA or *YYES points to an
   array allocated with YYSTACK_ALLOC.  yy_lac may overwrite the
   contents of either array, alter *YYES and *YYES_CAPACITY, and free
   any old *YYES other than YYESA.  */
static int
yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
        YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken)
{
  yy_state_t *yyes_prev = yyssp;
  yy_state_t *yyesp = yyes_prev;
  /* Reduce until we encounter a shift and thereby accept the token.  */
  YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken)));
  if (yytoken == YYSYMBOL_YYUNDEF)
    {
      YYDPRINTF ((stderr, " Always Err\n"));
      return 1;
    }
  while (1)
    {
      int yyrule = yypact[+*yyesp];
      if (yypact_value_is_default (yyrule)
          || (yyrule += yytoken) < 0 || YYLAST < yyrule
          || yycheck[yyrule] != yytoken)
        {
          /* Use the default action.  */
          yyrule = yydefact[+*yyesp];
          if (yyrule == 0)
            {
              YYDPRINTF ((stderr, " Err\n"));
              return 1;
            }
        }
      else
        {
          /* Use the action from yytable.  */
          yyrule = yytable[yyrule];
          if (yytable_value_is_error (yyrule))
            {
              YYDPRINTF ((stderr, " Err\n"));
              return 1;
            }
          if (0 < yyrule)
            {
              YYDPRINTF ((stderr, " S%d\n", yyrule));
              return 0;
            }
          yyrule = -yyrule;
        }
      /* By now we know we have to simulate a reduce.  */
      YYDPRINTF ((stderr, " R%d", yyrule - 1));
      {
        /* Pop the corresponding number of values from the stack.  */
        YYPTRDIFF_T yylen = yyr2[yyrule];
        /* First pop from the LAC stack as many tokens as possible.  */
        if (yyesp != yyes_prev)
          {
            YYPTRDIFF_T yysize = yyesp - *yyes + 1;
            if (yylen < yysize)
              {
                yyesp -= yylen;
                yylen = 0;
              }
            else
              {
                yyesp = yyes_prev;
                yylen -= yysize;
              }
          }
        /* Only afterwards look at the main stack.  */
        if (yylen)
          yyesp = yyes_prev -= yylen;
      }
      /* Push the resulting state of the reduction.  */
      {
        yy_state_fast_t yystate;
        {
          const int yylhs = yyr1[yyrule] - YYNTOKENS;
          const int yyi = yypgoto[yylhs] + *yyesp;
          yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
                     ? yytable[yyi]
                     : yydefgoto[yylhs]);
        }
        if (yyesp == yyes_prev)
          {
            yyesp = *yyes;
            YY_IGNORE_USELESS_CAST_BEGIN
            *yyesp = YY_CAST (yy_state_t, yystate);
            YY_IGNORE_USELESS_CAST_END
          }
        else
          {
            if (yy_lac_stack_realloc (yyes_capacity, 1,
#if MENT_DEBUG
                                      " (", ")",
#endif
                                      yyes, yyesa, &yyesp, yyes_prev))
              {
                YYDPRINTF ((stderr, "\n"));
                return YYENOMEM;
              }
            YY_IGNORE_USELESS_CAST_BEGIN
            *++yyesp = YY_CAST (yy_state_t, yystate);
            YY_IGNORE_USELESS_CAST_END
          }
        YYDPRINTF ((stderr, " G%d", yystate));
      }
    }
}

/* Context of a parse error.  */
typedef struct
{
  yy_state_t *yyssp;
  yy_state_t *yyesa;
  yy_state_t **yyes;
  YYPTRDIFF_T *yyes_capacity;
  yysymbol_kind_t yytoken;
  YYLTYPE *yylloc;
} yypcontext_t;

/* Put in YYARG at most YYARGN of the expected tokens given the
   current YYCTX, and return the number of tokens stored in YYARG.  If
   YYARG is null, return the number of expected tokens (guaranteed to
   be less than YYNTOKENS).  Return YYENOMEM on memory exhaustion.
   Return 0 if there are more than YYARGN expected tokens, yet fill
   YYARG up to YYARGN. */
static int
yypcontext_expected_tokens (const yypcontext_t *yyctx,
                            yysymbol_kind_t yyarg[], int yyargn)
{
  /* Actual size of YYARG. */
  int yycount = 0;

  int yyx;
  for (yyx = 0; yyx < YYNTOKENS; ++yyx)
    {
      yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
      if (yysym != YYSYMBOL_YYerror && yysym != YYSYMBOL_YYUNDEF)
        switch (yy_lac (yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym))
          {
          case YYENOMEM:
            return YYENOMEM;
          case 1:
            continue;
          default:
            if (!yyarg)
              ++yycount;
            else if (yycount == yyargn)
              return 0;
            else
              yyarg[yycount++] = yysym;
          }
    }
  if (yyarg && yycount == 0 && 0 < yyargn)
    yyarg[0] = YYSYMBOL_YYEMPTY;
  return yycount;
}




#ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
#  define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
# else
/* Return the length of YYSTR.  */
static YYPTRDIFF_T
yystrlen (const char *yystr)
{
  YYPTRDIFF_T yylen;
  for (yylen = 0; yystr[yylen]; yylen++)
    continue;
  return yylen;
}
# endif
#endif

#ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
#  define yystpcpy stpcpy
# else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
static char *
yystpcpy (char *yydest, const char *yysrc)
{
  char *yyd = yydest;
  const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
# endif
#endif

#ifndef yytnamerr
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   quotes and backslashes, so that it's suitable for yyerror.  The
   heuristic is that double-quoting is unnecessary unless the string
   contains an apostrophe, a comma, or backslash (other than
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   null, do not copy; instead, return the length of what the result
   would have been.  */
static YYPTRDIFF_T
yytnamerr (char *yyres, const char *yystr)
{
  if (*yystr == '"')
    {
      YYPTRDIFF_T yyn = 0;
      char const *yyp = yystr;
      for (;;)
        switch (*++yyp)
          {
          case '\'':
          case ',':
            goto do_not_strip_quotes;

          case '\\':
            if (*++yyp != '\\')
              goto do_not_strip_quotes;
            else
              goto append;

          append:
          default:
            if (yyres)
              yyres[yyn] = *yyp;
            yyn++;
            break;

          case '"':
            if (yyres)
              yyres[yyn] = '\0';
            return yyn;
          }
    do_not_strip_quotes: ;
    }

  if (yyres)
    return yystpcpy (yyres, yystr) - yyres;
  else
    return yystrlen (yystr);
}
#endif


static int
yy_syntax_error_arguments (const yypcontext_t *yyctx,
                           yysymbol_kind_t yyarg[], int yyargn)
{
  /* Actual size of YYARG. */
  int yycount = 0;
  /* There are many possibilities here to consider:
     - If this state is a consistent state with a default action, then
       the only way this function was invoked is if the default action
       is an error action.  In that case, don't check for expected
       tokens because there are none.
     - The only way there can be no lookahead present (in yychar) is if
       this state is a consistent state with a default action.  Thus,
       detecting the absence of a lookahead is sufficient to determine
       that there is no unexpected or expected token to report.  In that
       case, just report a simple "syntax error".
     - Don't assume there isn't a lookahead just because this state is a
       consistent state with a default action.  There might have been a
       previous inconsistent state, consistent state with a non-default
       action, or user semantic action that manipulated yychar.
       In the first two cases, it might appear that the current syntax
       error should have been detected in the previous state when yy_lac
       was invoked.  However, at that time, there might have been a
       different syntax error that discarded a different initial context
       during error recovery, leaving behind the current lookahead.
  */
  if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
    {
      int yyn;
      YYDPRINTF ((stderr, "Constructing syntax error message\n"));
      if (yyarg)
        yyarg[yycount] = yyctx->yytoken;
      ++yycount;
      yyn = yypcontext_expected_tokens (yyctx,
                                        yyarg ? yyarg + 1 : yyarg, yyargn - 1);
      if (yyn == YYENOMEM)
        return YYENOMEM;
      else if (yyn == 0)
        YYDPRINTF ((stderr, "No expected tokens.\n"));
      else
        yycount += yyn;
    }
  return yycount;
}

/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
   about the unexpected token YYTOKEN for the state stack whose top is
   YYSSP.  In order to see if a particular token T is a
   valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).

   Return 0 if *YYMSG was successfully written.  Return -1 if *YYMSG is
   not large enough to hold the message.  In that case, also set
   *YYMSG_ALLOC to the required number of bytes.  Return YYENOMEM if the
   required number of bytes is too large to store or if
   yy_lac returned YYENOMEM.  */
static int
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
                const yypcontext_t *yyctx)
{
  enum { YYARGS_MAX = 5 };
  /* Internationalized format string. */
  const char *yyformat = YY_NULLPTR;
  /* Arguments of yyformat: reported tokens (one for the "unexpected",
     one per "expected"). */
  yysymbol_kind_t yyarg[YYARGS_MAX];
  /* Cumulated lengths of YYARG.  */
  YYPTRDIFF_T yysize = 0;

  /* Actual size of YYARG. */
  int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
  if (yycount == YYENOMEM)
    return YYENOMEM;

  switch (yycount)
    {
#define YYCASE_(N, S)                       \
      case N:                               \
        yyformat = S;                       \
        break
    default: /* Avoid compiler warnings. */
      YYCASE_(0, YY_("syntax error"));
      YYCASE_(1, YY_("syntax error, unexpected %s"));
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_
    }

  /* Compute error message size.  Don't count the "%s"s, but reserve
     room for the terminator.  */
  yysize = yystrlen (yyformat) - 2 * yycount + 1;
  {
    int yyi;
    for (yyi = 0; yyi < yycount; ++yyi)
      {
        YYPTRDIFF_T yysize1
          = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
        if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
          yysize = yysize1;
        else
          return YYENOMEM;
      }
  }

  if (*yymsg_alloc < yysize)
    {
      *yymsg_alloc = 2 * yysize;
      if (! (yysize <= *yymsg_alloc
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
      return -1;
    }

  /* Avoid sprintf, as that infringes on the user's name space.
     Don't have undefined behavior even if the translation
     produced a string with the wrong number of "%s"s.  */
  {
    char *yyp = *yymsg;
    int yyi = 0;
    while ((*yyp = *yyformat) != '\0')
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
        {
          yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
          yyformat += 2;
        }
      else
        {
          ++yyp;
          ++yyformat;
        }
  }
  return 0;
}


/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

static void
yydestruct (const char *yymsg,
            yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, ment::SQLParserResult* result, yyscan_t scanner)
{
  YYUSE (yyvaluep);
  YYUSE (yylocationp);
  YYUSE (result);
  YYUSE (scanner);
  if (!yymsg)
    yymsg = "Deleting";
  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  switch (yykind)
    {
    case YYSYMBOL_IDENTIFIER: /* IDENTIFIER  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2127 "bison_parser.cpp"
        break;

    case YYSYMBOL_STRING: /* STRING  */
#line 203 "bison_parser.y"
            { free( (((*yyvaluep).sval)) ); }
#line 2133 "bison_parser.cpp"
        break;

    case YYSYMBOL_FLOATVAL: /* FLOATVAL  */
#line 201 "bison_parser.y"
            { }
#line 2139 "bison_parser.cpp"
        break;

    case YYSYMBOL_INTVAL: /* INTVAL  */
#line 201 "bison_parser.y"
            { }
#line 2145 "bison_parser.cpp"
        break;

    case YYSYMBOL_statement_list: /* statement_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).stmt_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).stmt_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).stmt_vec));
}
#line 2158 "bison_parser.cpp"
        break;

    case YYSYMBOL_statement: /* statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).statement)); }
#line 2164 "bison_parser.cpp"
        break;

    case YYSYMBOL_preparable_statement: /* preparable_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).statement)); }
#line 2170 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_hints: /* opt_hints  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).stat_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).stat_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).stat_vec));
}
#line 2183 "bison_parser.cpp"
        break;

    case YYSYMBOL_hint_list: /* hint_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).stat_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).stat_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).stat_vec));
}
#line 2196 "bison_parser.cpp"
        break;

    case YYSYMBOL_hint: /* hint  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2202 "bison_parser.cpp"
        break;

    case YYSYMBOL_prepare_statement: /* prepare_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).prep_stmt)); }
#line 2208 "bison_parser.cpp"
        break;

    case YYSYMBOL_prepare_target_query: /* prepare_target_query  */
#line 203 "bison_parser.y"
            { free( (((*yyvaluep).sval)) ); }
#line 2214 "bison_parser.cpp"
        break;

    case YYSYMBOL_execute_statement: /* execute_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).exec_stmt)); }
#line 2220 "bison_parser.cpp"
        break;

    case YYSYMBOL_import_statement: /* import_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).import_stmt)); }
#line 2226 "bison_parser.cpp"
        break;

    case YYSYMBOL_import_file_type: /* import_file_type  */
#line 201 "bison_parser.y"
            { }
#line 2232 "bison_parser.cpp"
        break;

    case YYSYMBOL_file_path: /* file_path  */
#line 203 "bison_parser.y"
            { free( (((*yyvaluep).sval)) ); }
#line 2238 "bison_parser.cpp"
        break;

    case YYSYMBOL_show_statement: /* show_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).show_stmt)); }
#line 2244 "bison_parser.cpp"
        break;

    case YYSYMBOL_use_statement: /* use_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).use_stmt)); }
#line 2250 "bison_parser.cpp"
        break;

    case YYSYMBOL_create_statement: /* create_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).create_stmt)); }
#line 2256 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_not_exists: /* opt_not_exists  */
#line 201 "bison_parser.y"
            { }
#line 2262 "bison_parser.cpp"
        break;

    case YYSYMBOL_column_def_commalist: /* column_def_commalist  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).column_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).column_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).column_vec));
}
#line 2275 "bison_parser.cpp"
        break;

    case YYSYMBOL_column_def: /* column_def  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).column_t)); }
#line 2281 "bison_parser.cpp"
        break;

    case YYSYMBOL_column_type: /* column_type  */
#line 201 "bison_parser.y"
            { }
#line 2287 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_column_nullable: /* opt_column_nullable  */
#line 201 "bison_parser.y"
            { }
#line 2293 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_primary_key: /* opt_primary_key  */
#line 201 "bison_parser.y"
            { }
#line 2299 "bison_parser.cpp"
        break;

    case YYSYMBOL_drop_statement: /* drop_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).drop_stmt)); }
#line 2305 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_exists: /* opt_exists  */
#line 201 "bison_parser.y"
            { }
#line 2311 "bison_parser.cpp"
        break;

    case YYSYMBOL_delete_statement: /* delete_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).delete_stmt)); }
#line 2317 "bison_parser.cpp"
        break;

    case YYSYMBOL_truncate_statement: /* truncate_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).delete_stmt)); }
#line 2323 "bison_parser.cpp"
        break;

    case YYSYMBOL_insert_statement: /* insert_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).insert_stmt)); }
#line 2329 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_column_list: /* opt_column_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).str_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).str_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).str_vec));
}
#line 2342 "bison_parser.cpp"
        break;

    case YYSYMBOL_update_statement: /* update_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).update_stmt)); }
#line 2348 "bison_parser.cpp"
        break;

    case YYSYMBOL_update_clause_commalist: /* update_clause_commalist  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).update_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).update_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).update_vec));
}
#line 2361 "bison_parser.cpp"
        break;

    case YYSYMBOL_update_clause: /* update_clause  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).update_t)); }
#line 2367 "bison_parser.cpp"
        break;

    case YYSYMBOL_select_statement: /* select_statement  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).select_stmt)); }
#line 2373 "bison_parser.cpp"
        break;

    case YYSYMBOL_select_with_paren: /* select_with_paren  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).select_stmt)); }
#line 2379 "bison_parser.cpp"
        break;

    case YYSYMBOL_select_paren_or_clause: /* select_paren_or_clause  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).select_stmt)); }
#line 2385 "bison_parser.cpp"
        break;

    case YYSYMBOL_select_no_paren: /* select_no_paren  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).select_stmt)); }
#line 2391 "bison_parser.cpp"
        break;

    case YYSYMBOL_select_clause: /* select_clause  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).select_stmt)); }
#line 2397 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_distinct: /* opt_distinct  */
#line 201 "bison_parser.y"
            { }
#line 2403 "bison_parser.cpp"
        break;

    case YYSYMBOL_select_list: /* select_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).stat_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).stat_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).stat_vec));
}
#line 2416 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_from_clause: /* opt_from_clause  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2422 "bison_parser.cpp"
        break;

    case YYSYMBOL_from_clause: /* from_clause  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2428 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_where: /* opt_where  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2434 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_group: /* opt_group  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).group_t)); }
#line 2440 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_having: /* opt_having  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2446 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_order: /* opt_order  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).order_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).order_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).order_vec));
}
#line 2459 "bison_parser.cpp"
        break;

    case YYSYMBOL_order_list: /* order_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).order_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).order_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).order_vec));
}
#line 2472 "bison_parser.cpp"
        break;

    case YYSYMBOL_order_desc: /* order_desc  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).order)); }
#line 2478 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_order_type: /* opt_order_type  */
#line 201 "bison_parser.y"
            { }
#line 2484 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_top: /* opt_top  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).limit)); }
#line 2490 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_limit: /* opt_limit  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).limit)); }
#line 2496 "bison_parser.cpp"
        break;

    case YYSYMBOL_stat_list: /* stat_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).stat_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).stat_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).stat_vec));
}
#line 2509 "bison_parser.cpp"
        break;

    case YYSYMBOL_literal_list: /* literal_list  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).stat_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).stat_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).stat_vec));
}
#line 2522 "bison_parser.cpp"
        break;

    case YYSYMBOL_stat_alias: /* stat_alias  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2528 "bison_parser.cpp"
        break;

    case YYSYMBOL_stat: /* stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2534 "bison_parser.cpp"
        break;

    case YYSYMBOL_operand: /* operand  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2540 "bison_parser.cpp"
        break;

    case YYSYMBOL_scalar_stat: /* scalar_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2546 "bison_parser.cpp"
        break;

    case YYSYMBOL_unary_stat: /* unary_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2552 "bison_parser.cpp"
        break;

    case YYSYMBOL_binary_stat: /* binary_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2558 "bison_parser.cpp"
        break;

    case YYSYMBOL_logic_stat: /* logic_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2564 "bison_parser.cpp"
        break;

    case YYSYMBOL_in_stat: /* in_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2570 "bison_parser.cpp"
        break;

    case YYSYMBOL_case_stat: /* case_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2576 "bison_parser.cpp"
        break;

    case YYSYMBOL_case_list: /* case_list  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2582 "bison_parser.cpp"
        break;

    case YYSYMBOL_exists_stat: /* exists_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2588 "bison_parser.cpp"
        break;

    case YYSYMBOL_comp_stat: /* comp_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2594 "bison_parser.cpp"
        break;

    case YYSYMBOL_function_stat: /* function_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2600 "bison_parser.cpp"
        break;

    case YYSYMBOL_extract_stat: /* extract_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2606 "bison_parser.cpp"
        break;

    case YYSYMBOL_datetime_field: /* datetime_field  */
#line 201 "bison_parser.y"
            { }
#line 2612 "bison_parser.cpp"
        break;

    case YYSYMBOL_array_stat: /* array_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2618 "bison_parser.cpp"
        break;

    case YYSYMBOL_array_index: /* array_index  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2624 "bison_parser.cpp"
        break;

    case YYSYMBOL_between_stat: /* between_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2630 "bison_parser.cpp"
        break;

    case YYSYMBOL_column_name: /* column_name  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2636 "bison_parser.cpp"
        break;

    case YYSYMBOL_literal: /* literal  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2642 "bison_parser.cpp"
        break;

    case YYSYMBOL_string_literal: /* string_literal  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2648 "bison_parser.cpp"
        break;

    case YYSYMBOL_bool_literal: /* bool_literal  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2654 "bison_parser.cpp"
        break;

    case YYSYMBOL_num_literal: /* num_literal  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2660 "bison_parser.cpp"
        break;

    case YYSYMBOL_int_literal: /* int_literal  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2666 "bison_parser.cpp"
        break;

    case YYSYMBOL_null_literal: /* null_literal  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2672 "bison_parser.cpp"
        break;

    case YYSYMBOL_param_stat: /* param_stat  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2678 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_ref: /* table_ref  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2684 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_ref_atomic: /* table_ref_atomic  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2690 "bison_parser.cpp"
        break;

    case YYSYMBOL_nonjoin_table_ref_atomic: /* nonjoin_table_ref_atomic  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2696 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_ref_commalist: /* table_ref_commalist  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).table_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).table_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).table_vec));
}
#line 2709 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_ref_name: /* table_ref_name  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2715 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_ref_name_no_alias: /* table_ref_name_no_alias  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2721 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_name: /* table_name  */
#line 202 "bison_parser.y"
            { free( (((*yyvaluep).table_name).name) ); free( (((*yyvaluep).table_name).schema) ); }
#line 2727 "bison_parser.cpp"
        break;

    case YYSYMBOL_table_alias: /* table_alias  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).alias_t)); }
#line 2733 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_table_alias: /* opt_table_alias  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).alias_t)); }
#line 2739 "bison_parser.cpp"
        break;

    case YYSYMBOL_alias: /* alias  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).alias_t)); }
#line 2745 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_alias: /* opt_alias  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).alias_t)); }
#line 2751 "bison_parser.cpp"
        break;

    case YYSYMBOL_join_clause: /* join_clause  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).table)); }
#line 2757 "bison_parser.cpp"
        break;

    case YYSYMBOL_opt_join_type: /* opt_join_type  */
#line 201 "bison_parser.y"
            { }
#line 2763 "bison_parser.cpp"
        break;

    case YYSYMBOL_join_condition: /* join_condition  */
#line 212 "bison_parser.y"
            { delete (((*yyvaluep).stat)); }
#line 2769 "bison_parser.cpp"
        break;

    case YYSYMBOL_ident_commalist: /* ident_commalist  */
#line 204 "bison_parser.y"
            {
	if ((((*yyvaluep).str_vec)) != nullptr) {
		for (auto ptr : *(((*yyvaluep).str_vec))) {
			delete ptr;
		}
	}
	delete (((*yyvaluep).str_vec));
}
#line 2782 "bison_parser.cpp"
        break;

      default:
        break;
    }
  YY_IGNORE_MAYBE_UNINITIALIZED_END
}






/*----------.
| yyparse.  |
`----------*/

int
yyparse (ment::SQLParserResult* result, yyscan_t scanner)
{
/* Lookahead token kind.  */
int yychar;


/* The semantic value of the lookahead symbol.  */
/* Default value used for initialization, for pacifying older GCCs
   or non-GCC compilers.  */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);

/* Location data for the lookahead symbol.  */
static YYLTYPE yyloc_default
# if defined MENT_LTYPE_IS_TRIVIAL && MENT_LTYPE_IS_TRIVIAL
  = { 1, 1, 1, 1 }
# endif
;
YYLTYPE yylloc = yyloc_default;

    /* Number of syntax errors so far.  */
    int yynerrs = 0;

    yy_state_fast_t yystate = 0;
    /* Number of tokens to shift before error messages enabled.  */
    int yyerrstatus = 0;

    /* Refer to the stacks through separate pointers, to allow yyoverflow
       to reallocate them elsewhere.  */

    /* Their size.  */
    YYPTRDIFF_T yystacksize = YYINITDEPTH;

    /* The state stack: array, bottom, top.  */
    yy_state_t yyssa[YYINITDEPTH];
    yy_state_t *yyss = yyssa;
    yy_state_t *yyssp = yyss;

    /* The semantic value stack: array, bottom, top.  */
    YYSTYPE yyvsa[YYINITDEPTH];
    YYSTYPE *yyvs = yyvsa;
    YYSTYPE *yyvsp = yyvs;

    /* The location stack: array, bottom, top.  */
    YYLTYPE yylsa[YYINITDEPTH];
    YYLTYPE *yyls = yylsa;
    YYLTYPE *yylsp = yyls;

    yy_state_t yyesa[20];
    yy_state_t *yyes = yyesa;
    YYPTRDIFF_T yyes_capacity = 20 < YYMAXDEPTH ? 20 : YYMAXDEPTH;

  /* Whether LAC context is established.  A Boolean.  */
  int yy_lac_established = 0;
  int yyn;
  /* The return value of yyparse.  */
  int yyresult;
  /* Lookahead symbol kind.  */
  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;
  YYLTYPE yyloc;

  /* The locations where the error started and ended.  */
  YYLTYPE yyerror_range[3];

  /* Buffer for error messages, and its allocated size.  */
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;

#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))

  /* The number of symbols on the RHS of the reduced rule.
     Keep to zero when no symbol should be popped.  */
  int yylen = 0;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yychar = SQL_MENT_EMPTY; /* Cause a token to be read.  */

/* User initialization code.  */
#line 128 "bison_parser.y"
{
    yylloc.first_line = 1;
    yylloc.last_line = 1;
    yylloc.first_column = 1;
    yylloc.last_column = 1;
    yylloc.total_column = 0;
    yylloc.string_length = 0;


	//9.13
	g_colPos.clear();          // 清空上次残留
	g_valuePos.clear();
	g_colPosMoved = false;
}

#line 2900 "bison_parser.cpp"

  yylsp[0] = yylloc;
  goto yysetstate;


/*------------------------------------------------------------.
| yynewstate -- push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed.  So pushing a state here evens the stacks.  */
  yyssp++;


/*--------------------------------------------------------------------.
| yysetstate -- set current state (the top of the stack) to yystate.  |
`--------------------------------------------------------------------*/
yysetstate:
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
  YY_IGNORE_USELESS_CAST_BEGIN
  *yyssp = YY_CAST (yy_state_t, yystate);
  YY_IGNORE_USELESS_CAST_END
  YY_STACK_PRINT (yyss, yyssp);

  if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
    goto yyexhaustedlab;
#else
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYPTRDIFF_T yysize = yyssp - yyss + 1;

# if defined yyoverflow
      {
        /* Give user a chance to reallocate the stack.  Use copies of
           these so that the &'s don't force the real ones into
           memory.  */
        yy_state_t *yyss1 = yyss;
        YYSTYPE *yyvs1 = yyvs;
        YYLTYPE *yyls1 = yyls;

        /* Each stack pointer address is followed by the size of the
           data in use in that stack, in bytes.  This used to be a
           conditional around just the two extra args, but that might
           be undefined if yyoverflow is a macro.  */
        yyoverflow (YY_("memory exhausted"),
                    &yyss1, yysize * YYSIZEOF (*yyssp),
                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
                    &yyls1, yysize * YYSIZEOF (*yylsp),
                    &yystacksize);
        yyss = yyss1;
        yyvs = yyvs1;
        yyls = yyls1;
      }
# else /* defined YYSTACK_RELOCATE */
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
        yystacksize = YYMAXDEPTH;

      {
        yy_state_t *yyss1 = yyss;
        union yyalloc *yyptr =
          YY_CAST (union yyalloc *,
                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
        if (! yyptr)
          goto yyexhaustedlab;
        YYSTACK_RELOCATE (yyss_alloc, yyss);
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
        YYSTACK_RELOCATE (yyls_alloc, yyls);
#  undef YYSTACK_RELOCATE
        if (yyss1 != yyssa)
          YYSTACK_FREE (yyss1);
      }
# endif

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      yylsp = yyls + yysize - 1;

      YY_IGNORE_USELESS_CAST_BEGIN
      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
                  YY_CAST (long, yystacksize)));
      YY_IGNORE_USELESS_CAST_END

      if (yyss + yystacksize - 1 <= yyssp)
        YYABORT;
    }
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */

  if (yystate == YYFINAL)
    YYACCEPT;

  goto yybackup;


/*-----------.
| yybackup.  |
`-----------*/
yybackup:
  /* Do appropriate processing given the current state.  Read a
     lookahead token if we need one and don't already have one.  */

  /* First try to decide what to do without reference to lookahead token.  */
  yyn = yypact[yystate];
  if (yypact_value_is_default (yyn))
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
  if (yychar == SQL_MENT_EMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token\n"));
      yychar = yylex (&yylval, &yylloc, scanner);
    }

  if (yychar <= SQL_YYEOF)
    {
      yychar = SQL_YYEOF;
      yytoken = YYSYMBOL_YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else if (yychar == SQL_MENT_error)
    {
      /* The scanner already issued an error message, process directly
         to error recovery.  But do not keep the error token as
         lookahead, it is too special and may lead us to an endless
         loop in error recovery. */
      yychar = SQL_MENT_UNDEF;
      yytoken = YYSYMBOL_YYerror;
      yyerror_range[1] = yylloc;
      goto yyerrlab1;
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    {
      YY_LAC_ESTABLISH;
      goto yydefault;
    }
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yytable_value_is_error (yyn))
        goto yyerrlab;
      YY_LAC_ESTABLISH;
      yyn = -yyn;
      goto yyreduce;
    }

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  /* Shift the lookahead token.  */
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
  yystate = yyn;
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END
  *++yylsp = yylloc;

  /* Discard the shifted token.  */
  yychar = SQL_MENT_EMPTY;
  YY_LAC_DISCARD ("shift");
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     '$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];

  /* Default location. */
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  yyerror_range[1] = yyloc;
  YY_REDUCE_PRINT (yyn);
  {
    int yychar_backup = yychar;
    switch (yyn)
      {
  case 2: /* input: %empty  */
#line 327 "bison_parser.y"
                                   { /* 纯空行/注释行: 直接返回，不报错误 */ }
#line 3119 "bison_parser.cpp"
    break;

  case 3: /* input: statement_list ';'  */
#line 329 "bison_parser.y"
    {
        for (SQLStatement* stmt : *(yyvsp[-1].stmt_vec)) {
            result->addStatement(stmt);
        }

        unsigned param_id = 0;
        for (void* param : yyloc.param_list) {
            if (param != nullptr) {
                Stat* stat = (Stat*) param;
                stat->ival = param_id;
                result->addParameter(stat);
                ++param_id;
            }
        }
        delete (yyvsp[-1].stmt_vec);
    }
#line 3140 "bison_parser.cpp"
    break;

  case 4: /* input: statement_list  */
#line 346 "bison_parser.y"
    {
        result->setIsValid(false);
		char buf[256];
		snprintf(buf, sizeof(buf),
				"Syntax error: missing semicolon at end of statement near line %d, column %d",
				(yylsp[0]).last_line, (yylsp[0]).last_column);
		result->setErrorDetails(strdup(buf), (yylsp[0]).last_line, (yylsp[0]).last_column);

		//清理 $1，避免内存泄漏
		for (SQLStatement* stmt : *(yyvsp[0].stmt_vec)) {
			delete stmt;
		}
		delete (yyvsp[0].stmt_vec);

		YYERROR;
    }
#line 3161 "bison_parser.cpp"
    break;

  case 5: /* input: SQL_ILLEGAL  */
#line 363 "bison_parser.y"
    {
        result->setIsValid(false);
        YYERROR;
    }
#line 3170 "bison_parser.cpp"
    break;

  case 6: /* statement_list: statement  */
#line 371 "bison_parser.y"
                          {
			(yyvsp[0].statement)->stringLength = yylloc.string_length;
			yylloc.string_length = 0;
			(yyval.stmt_vec) = new std::vector<SQLStatement*>();
			(yyval.stmt_vec)->push_back((yyvsp[0].statement));
		}
#line 3181 "bison_parser.cpp"
    break;

  case 7: /* statement_list: statement_list ';' statement  */
#line 377 "bison_parser.y"
                                             {
			(yyvsp[0].statement)->stringLength = yylloc.string_length;
			yylloc.string_length = 0;
			(yyvsp[-2].stmt_vec)->push_back((yyvsp[0].statement));
			(yyval.stmt_vec) = (yyvsp[-2].stmt_vec);
		}
#line 3192 "bison_parser.cpp"
    break;

  case 8: /* statement: prepare_statement opt_hints  */
#line 386 "bison_parser.y"
                                            {
			(yyval.statement) = (yyvsp[-1].prep_stmt);
			(yyval.statement)->hints = (yyvsp[0].stat_vec);
		}
#line 3201 "bison_parser.cpp"
    break;

  case 9: /* statement: preparable_statement opt_hints  */
#line 390 "bison_parser.y"
                                               {
			(yyval.statement) = (yyvsp[-1].statement);
			(yyval.statement)->hints = (yyvsp[0].stat_vec);
		}
#line 3210 "bison_parser.cpp"
    break;

  case 10: /* statement: show_statement  */
#line 394 "bison_parser.y"
                               {
			(yyval.statement) = (yyvsp[0].show_stmt);
		}
#line 3218 "bison_parser.cpp"
    break;

  case 11: /* statement: use_statement  */
#line 397 "bison_parser.y"
                       {
			(yyval.statement) = (yyvsp[0].use_stmt);
	}
#line 3226 "bison_parser.cpp"
    break;

  case 12: /* preparable_statement: select_statement  */
#line 404 "bison_parser.y"
                                 { (yyval.statement) = (yyvsp[0].select_stmt); }
#line 3232 "bison_parser.cpp"
    break;

  case 13: /* preparable_statement: import_statement  */
#line 405 "bison_parser.y"
                                 { (yyval.statement) = (yyvsp[0].import_stmt); }
#line 3238 "bison_parser.cpp"
    break;

  case 14: /* preparable_statement: create_statement  */
#line 406 "bison_parser.y"
                                 { (yyval.statement) = (yyvsp[0].create_stmt); }
#line 3244 "bison_parser.cpp"
    break;

  case 15: /* preparable_statement: insert_statement  */
#line 407 "bison_parser.y"
                                 { (yyval.statement) = (yyvsp[0].insert_stmt); }
#line 3250 "bison_parser.cpp"
    break;

  case 16: /* preparable_statement: delete_statement  */
#line 408 "bison_parser.y"
                                 { (yyval.statement) = (yyvsp[0].delete_stmt); }
#line 3256 "bison_parser.cpp"
    break;

  case 17: /* preparable_statement: truncate_statement  */
#line 409 "bison_parser.y"
                                   { (yyval.statement) = (yyvsp[0].delete_stmt); }
#line 3262 "bison_parser.cpp"
    break;

  case 18: /* preparable_statement: update_statement  */
#line 410 "bison_parser.y"
                                 { (yyval.statement) = (yyvsp[0].update_stmt); }
#line 3268 "bison_parser.cpp"
    break;

  case 19: /* preparable_statement: drop_statement  */
#line 411 "bison_parser.y"
                               { (yyval.statement) = (yyvsp[0].drop_stmt); }
#line 3274 "bison_parser.cpp"
    break;

  case 20: /* preparable_statement: execute_statement  */
#line 412 "bison_parser.y"
                                  { (yyval.statement) = (yyvsp[0].exec_stmt); }
#line 3280 "bison_parser.cpp"
    break;

  case 21: /* opt_hints: WITH HINT '(' hint_list ')'  */
#line 421 "bison_parser.y"
                                { (yyval.stat_vec) = (yyvsp[-1].stat_vec); }
#line 3286 "bison_parser.cpp"
    break;

  case 22: /* opt_hints: %empty  */
#line 422 "bison_parser.y"
                { (yyval.stat_vec) = nullptr; }
#line 3292 "bison_parser.cpp"
    break;

  case 23: /* hint_list: hint  */
#line 427 "bison_parser.y"
               { (yyval.stat_vec) = new std::vector<Stat*>(); (yyval.stat_vec)->push_back((yyvsp[0].stat)); }
#line 3298 "bison_parser.cpp"
    break;

  case 24: /* hint_list: hint_list ',' hint  */
#line 428 "bison_parser.y"
                             { (yyvsp[-2].stat_vec)->push_back((yyvsp[0].stat)); (yyval.stat_vec) = (yyvsp[-2].stat_vec); }
#line 3304 "bison_parser.cpp"
    break;

  case 25: /* hint: IDENTIFIER  */
#line 432 "bison_parser.y"
                           {
			(yyval.stat) = Stat::make(kStatHint);
			(yyval.stat)->name = (yyvsp[0].stat)->name;
		}
#line 3313 "bison_parser.cpp"
    break;

  case 26: /* hint: IDENTIFIER '(' literal_list ')'  */
#line 436 "bison_parser.y"
                                          {
			(yyval.stat) = Stat::make(kStatHint);
			(yyval.stat)->name = (yyvsp[-3].stat)->name;
			(yyval.stat)->statList = (yyvsp[-1].stat_vec);
		}
#line 3323 "bison_parser.cpp"
    break;

  case 27: /* prepare_statement: PREPARE IDENTIFIER FROM prepare_target_query  */
#line 448 "bison_parser.y"
                                                             {
			(yyval.prep_stmt) = new PrepareStatement();
			(yyval.prep_stmt)->name = (yyvsp[-2].stat)->name;
			(yyval.prep_stmt)->query = (yyvsp[0].sval);
		}
#line 3333 "bison_parser.cpp"
    break;

  case 29: /* execute_statement: EXECUTE IDENTIFIER  */
#line 458 "bison_parser.y"
                                   {
			(yyval.exec_stmt) = new ExecuteStatement();
			(yyval.exec_stmt)->name = (yyvsp[0].stat)->name;
		}
#line 3342 "bison_parser.cpp"
    break;

  case 30: /* execute_statement: EXECUTE IDENTIFIER '(' literal_list ')'  */
#line 462 "bison_parser.y"
                                                        {
			(yyval.exec_stmt) = new ExecuteStatement();
			(yyval.exec_stmt)->name = (yyvsp[-3].stat)->name;
			(yyval.exec_stmt)->parameters = (yyvsp[-1].stat_vec);
		}
#line 3352 "bison_parser.cpp"
    break;

  case 31: /* import_statement: IMPORT FROM import_file_type FILE file_path INTO table_name  */
#line 474 "bison_parser.y"
                                                                            {
			(yyval.import_stmt) = new ImportStatement((ImportType) (yyvsp[-4].uval));
			(yyval.import_stmt)->filePath = (yyvsp[-2].sval);
			(yyval.import_stmt)->schema = (yyvsp[0].table_name).schema;
			(yyval.import_stmt)->tableName = (yyvsp[0].table_name).name;
		}
#line 3363 "bison_parser.cpp"
    break;

  case 32: /* import_file_type: CSV  */
#line 483 "bison_parser.y"
                    { (yyval.uval) = kImportCSV; }
#line 3369 "bison_parser.cpp"
    break;

  case 33: /* file_path: string_literal  */
#line 487 "bison_parser.y"
                               { (yyval.sval) = _strdup((yyvsp[0].stat)->name); delete (yyvsp[0].stat); }
#line 3375 "bison_parser.cpp"
    break;

  case 34: /* show_statement: SHOW TABLES  */
#line 497 "bison_parser.y"
                            {
			(yyval.show_stmt) = new ShowStatement(kShowTables);
		}
#line 3383 "bison_parser.cpp"
    break;

  case 35: /* show_statement: SHOW COLUMNS table_name  */
#line 500 "bison_parser.y"
                                        {
			(yyval.show_stmt) = new ShowStatement(kShowColumns);
			(yyval.show_stmt)->schema = (yyvsp[0].table_name).schema;
			(yyval.show_stmt)->name = (yyvsp[0].table_name).name;
		}
#line 3393 "bison_parser.cpp"
    break;

  case 36: /* show_statement: SHOW SCHEMAS  */
#line 505 "bison_parser.y"
                       {
		(yyval.show_stmt) = new ShowStatement(kShowSchemas);
	}
#line 3401 "bison_parser.cpp"
    break;

  case 37: /* use_statement: USE table_name  */
#line 516 "bison_parser.y"
                              {
			(yyval.use_stmt)=new UseStatement();
			(yyval.use_stmt)->schema=(yyvsp[0].table_name).name;
		}
#line 3410 "bison_parser.cpp"
    break;

  case 38: /* create_statement: CREATE TABLE opt_not_exists table_name FROM TBL FILE file_path  */
#line 527 "bison_parser.y"
                                                                               {
			(yyval.create_stmt) = new CreateStatement(ForCreateTableFromTbl);
			(yyval.create_stmt)->ifNotExists = (yyvsp[-5].bval);
			(yyval.create_stmt)->schema = (yyvsp[-4].table_name).schema;
			(yyval.create_stmt)->tableName = (yyvsp[-4].table_name).name;
			(yyval.create_stmt)->filePath = (yyvsp[0].sval);
		}
#line 3422 "bison_parser.cpp"
    break;

  case 39: /* create_statement: CREATE TABLE opt_not_exists table_name '(' column_def_commalist ')'  */
#line 534 "bison_parser.y"
                                                                                    {
			(yyval.create_stmt) = new CreateStatement(ForCreateTable);
			(yyval.create_stmt)->ifNotExists = (yyvsp[-4].bval);
			(yyval.create_stmt)->schema = (yyvsp[-3].table_name).schema;
			(yyval.create_stmt)->tableName = (yyvsp[-3].table_name).name;
			(yyval.create_stmt)->columns = (yyvsp[-1].column_vec);
		}
#line 3434 "bison_parser.cpp"
    break;

  case 40: /* create_statement: CREATE VIEW opt_not_exists table_name opt_column_list AS select_statement  */
#line 541 "bison_parser.y"
                                                                                          {
			(yyval.create_stmt) = new CreateStatement(ForCreateView);
			(yyval.create_stmt)->ifNotExists = (yyvsp[-4].bval);
			(yyval.create_stmt)->schema = (yyvsp[-3].table_name).schema;
			(yyval.create_stmt)->tableName = (yyvsp[-3].table_name).name;
			(yyval.create_stmt)->viewColumns = (yyvsp[-2].str_vec);
			(yyval.create_stmt)->select = (yyvsp[0].select_stmt);
		}
#line 3447 "bison_parser.cpp"
    break;

  case 41: /* create_statement: CREATE SCHEMA table_name  */
#line 549 "bison_parser.y"
                                        {
			(yyval.create_stmt)=new CreateStatement(ForCreateSchema);
			(yyval.create_stmt)->schema =(yyvsp[0].table_name).name;
		}
#line 3456 "bison_parser.cpp"
    break;

  case 42: /* create_statement: CREATE INDEX ON table_name '(' table_name ')'  */
#line 553 "bison_parser.y"
                                                             {
			(yyval.create_stmt)=new CreateStatement(ForCreateIndex);
			(yyval.create_stmt)->schema = (yyvsp[-3].table_name).schema;
			(yyval.create_stmt)->tableName = (yyvsp[-3].table_name).name;
			(yyval.create_stmt)->onWhich =(yyvsp[-1].table_name).name;
		}
#line 3467 "bison_parser.cpp"
    break;

  case 43: /* opt_not_exists: IF NOT EXISTS  */
#line 562 "bison_parser.y"
                              { (yyval.bval) = true; }
#line 3473 "bison_parser.cpp"
    break;

  case 44: /* opt_not_exists: %empty  */
#line 563 "bison_parser.y"
                            { (yyval.bval) = false; }
#line 3479 "bison_parser.cpp"
    break;

  case 45: /* column_def_commalist: column_def  */
#line 567 "bison_parser.y"
                           { (yyval.column_vec) = new std::vector<ColumnDefinition*>(); (yyval.column_vec)->push_back((yyvsp[0].column_t)); }
#line 3485 "bison_parser.cpp"
    break;

  case 46: /* column_def_commalist: column_def_commalist ',' column_def  */
#line 568 "bison_parser.y"
                                                    { (yyvsp[-2].column_vec)->push_back((yyvsp[0].column_t)); (yyval.column_vec) = (yyvsp[-2].column_vec); }
#line 3491 "bison_parser.cpp"
    break;

  case 47: /* column_def: IDENTIFIER column_type opt_column_nullable opt_primary_key  */
#line 572 "bison_parser.y"
                                                                          {
			(yyval.column_t) = new ColumnDefinition((yyvsp[-3].stat)->name, (yyvsp[-2].column_type_t), (yyvsp[-1].bval));
			 (yyval.column_t)->isPrimaryKey = (yyvsp[0].bval);
		}
#line 3500 "bison_parser.cpp"
    break;

  case 48: /* column_type: INT  */
#line 579 "bison_parser.y"
                    { (yyval.column_type_t) = ColumnType{DataType::INT}; }
#line 3506 "bison_parser.cpp"
    break;

  case 49: /* column_type: INTEGER  */
#line 580 "bison_parser.y"
                        { (yyval.column_type_t) = ColumnType{DataType::INT}; }
#line 3512 "bison_parser.cpp"
    break;

  case 50: /* column_type: LONG  */
#line 581 "bison_parser.y"
                     { (yyval.column_type_t) = ColumnType{DataType::LONG}; }
#line 3518 "bison_parser.cpp"
    break;

  case 51: /* column_type: FLOAT  */
#line 582 "bison_parser.y"
                      { (yyval.column_type_t) = ColumnType{DataType::FLOAT}; }
#line 3524 "bison_parser.cpp"
    break;

  case 52: /* column_type: DOUBLE  */
#line 583 "bison_parser.y"
                       { (yyval.column_type_t) = ColumnType{DataType::DOUBLE}; }
#line 3530 "bison_parser.cpp"
    break;

  case 53: /* column_type: VARCHAR '(' INTVAL ')'  */
#line 584 "bison_parser.y"
                                       { (yyval.column_type_t) = ColumnType{DataType::VARCHAR, (yyvsp[-1].ival)}; }
#line 3536 "bison_parser.cpp"
    break;

  case 54: /* column_type: CHAR '(' INTVAL ')'  */
#line 585 "bison_parser.y"
                                    { (yyval.column_type_t) = ColumnType{DataType::CHAR, (yyvsp[-1].ival)}; }
#line 3542 "bison_parser.cpp"
    break;

  case 55: /* column_type: TEXT  */
#line 586 "bison_parser.y"
                     { (yyval.column_type_t) = ColumnType{DataType::TEXT}; }
#line 3548 "bison_parser.cpp"
    break;

  case 56: /* column_type: BOOL  */
#line 587 "bison_parser.y"
                 { (yyval.column_type_t) = ColumnType{DataType::BOOL}; }
#line 3554 "bison_parser.cpp"
    break;

  case 57: /* opt_column_nullable: NULL  */
#line 591 "bison_parser.y"
                     { (yyval.bval) = true; }
#line 3560 "bison_parser.cpp"
    break;

  case 58: /* opt_column_nullable: NOT NULL  */
#line 592 "bison_parser.y"
                         { (yyval.bval) = false; }
#line 3566 "bison_parser.cpp"
    break;

  case 59: /* opt_column_nullable: %empty  */
#line 593 "bison_parser.y"
                            { (yyval.bval) = false; }
#line 3572 "bison_parser.cpp"
    break;

  case 60: /* opt_primary_key: %empty  */
#line 597 "bison_parser.y"
                { 
        (yyval.bval) = false; 
        
    }
#line 3581 "bison_parser.cpp"
    break;

  case 61: /* opt_primary_key: PRIMARY_KEY  */
#line 601 "bison_parser.y"
                { 
        (yyval.bval) = true; 
        
    }
#line 3590 "bison_parser.cpp"
    break;

  case 62: /* opt_primary_key: PRIMARY KEY  */
#line 605 "bison_parser.y"
                {  // 添加这个分支处理分开的 PRIMARY KEY
        (yyval.bval) = true; 
        
    }
#line 3599 "bison_parser.cpp"
    break;

  case 63: /* drop_statement: DROP TABLE opt_exists table_name  */
#line 618 "bison_parser.y"
                                                 {
			(yyval.drop_stmt) = new DropStatement(kDropTable);
			(yyval.drop_stmt)->ifExists = (yyvsp[-1].bval);
			(yyval.drop_stmt)->schema = (yyvsp[0].table_name).schema;
			(yyval.drop_stmt)->name = (yyvsp[0].table_name).name;
		}
#line 3610 "bison_parser.cpp"
    break;

  case 64: /* drop_statement: DROP VIEW opt_exists table_name  */
#line 624 "bison_parser.y"
                                                {
			(yyval.drop_stmt) = new DropStatement(kDropView);
			(yyval.drop_stmt)->ifExists = (yyvsp[-1].bval);
			(yyval.drop_stmt)->schema = (yyvsp[0].table_name).schema;
			(yyval.drop_stmt)->name = (yyvsp[0].table_name).name;
		}
#line 3621 "bison_parser.cpp"
    break;

  case 65: /* drop_statement: DEALLOCATE PREPARE IDENTIFIER  */
#line 630 "bison_parser.y"
                                              {
			(yyval.drop_stmt) = new DropStatement(kDropPreparedStatement);
			(yyval.drop_stmt)->ifExists = false;
			(yyval.drop_stmt)->name = (yyvsp[0].stat)->name;
		}
#line 3631 "bison_parser.cpp"
    break;

  case 66: /* opt_exists: IF EXISTS  */
#line 638 "bison_parser.y"
                            { (yyval.bval) = true; }
#line 3637 "bison_parser.cpp"
    break;

  case 67: /* opt_exists: %empty  */
#line 639 "bison_parser.y"
                            { (yyval.bval) = false; }
#line 3643 "bison_parser.cpp"
    break;

  case 68: /* delete_statement: DELETE FROM table_name opt_where  */
#line 648 "bison_parser.y"
                                                 {
			(yyval.delete_stmt) = new DeleteStatement();
			(yyval.delete_stmt)->schema = (yyvsp[-1].table_name).schema;
			(yyval.delete_stmt)->tableName = (yyvsp[-1].table_name).name;
			(yyval.delete_stmt)->stat = (yyvsp[0].stat);

			(yyval.delete_stmt)->errorLine = (yylsp[-2]).first_line;
        	(yyval.delete_stmt)->errorColumn = (yylsp[-2]).first_column;

			if ((yyvsp[0].stat)) {
						(yyval.delete_stmt)->whereLine   = (yylsp[0]).first_line;
						(yyval.delete_stmt)->whereColumn = (yylsp[0]).first_column;
					}

			/* 仅当 WHERE 是“列 = 值”时才记录等值坐标 */
			if ((yyvsp[0].stat) && (yyvsp[0].stat)->opType == kOpEquals &&
				(yyvsp[0].stat)->stat  && (yyvsp[0].stat)->stat->type  == kStatColumnRef &&
				(yyvsp[0].stat)->stat2 && (yyvsp[0].stat)->stat2->isLiteral()) {
				(yyval.delete_stmt)->eqOpLine   = (yylsp[0]).first_line;
				(yyval.delete_stmt)->eqOpColumn = (yylsp[0]).first_column;
			}
		}
#line 3670 "bison_parser.cpp"
    break;

  case 69: /* truncate_statement: TRUNCATE table_name  */
#line 673 "bison_parser.y"
                                    {
			(yyval.delete_stmt) = new DeleteStatement();
			(yyval.delete_stmt)->schema = (yyvsp[0].table_name).schema;
			(yyval.delete_stmt)->tableName = (yyvsp[0].table_name).name;
		}
#line 3680 "bison_parser.cpp"
    break;

  case 70: /* insert_statement: INSERT INTO table_name opt_column_list VALUES '(' literal_list ')'  */
#line 686 "bison_parser.y"
                                                                           {
				//std::cout << "[BISON] enter insert_statement, g_colPos.size=" << g_colPos.size()<< "  VALUES-branch" << std::endl;
				//std::cout << "[BISON] enter insert_statement, g_colPos.size=" << g_colPos.size() << std::endl;
                (yyval.insert_stmt) = new InsertStatement(kInsertValues);
                (yyval.insert_stmt)->schema = (yyvsp[-5].table_name).schema;
                (yyval.insert_stmt)->tableName = (yyvsp[-5].table_name).name;
                (yyval.insert_stmt)->columns = (yyvsp[-4].str_vec);          // vector<char*>*
                (yyval.insert_stmt)->values = (yyvsp[-1].stat_vec);

				//9.14 本来是6
				(yyval.insert_stmt)->valuesLine   = (yylsp[-3]).first_line;
				(yyval.insert_stmt)->valuesColumn = (yylsp[-3]).first_column;

                /* 把收集到的列名坐标挂到语句上，并清空全局向量 */
				if ((yyvsp[-4].str_vec) && !g_colPos.empty() && !g_colPosMoved) {
					//std::cout << "[BISON] before move, g_colPos.size=" << g_colPos.size() << std::endl;
					(yyval.insert_stmt)->colPos = new std::vector<std::pair<std::string, std::pair<int,int>>>(std::move(g_colPos));
					g_colPosMoved = true;   // 标记已 move
					//std::cout << "[BISON] after move, g_colPos.size=" << g_colPos.size() << std::endl;
				} else {
					(yyval.insert_stmt)->colPos = nullptr;
				}

                (yyval.insert_stmt)->errorLine = (yylsp[-4]).first_line;
                (yyval.insert_stmt)->errorColumn = (yylsp[-4]).first_column;

				//std::cout << "[BISON] exit insert_statement, $$->colPos=" << $$->colPos << std::endl;
					//if ($$->colPos) {
						//std::cout << "[BISON] exit colPos size=" << $$->colPos->size() << std::endl;
					//}
        }
#line 3716 "bison_parser.cpp"
    break;

  case 71: /* insert_statement: INSERT INTO table_name opt_column_list select_no_paren  */
#line 717 "bison_parser.y"
                                                               {
				//std::cout << "[BISON] enter insert_statement, g_colPos.size=" << g_colPos.size()<< "  SELECT-branch" << std::endl;
                (yyval.insert_stmt) = new InsertStatement(kInsertSelect);
                (yyval.insert_stmt)->schema = (yyvsp[-2].table_name).schema;
                (yyval.insert_stmt)->tableName = (yyvsp[-2].table_name).name;
                (yyval.insert_stmt)->columns = (yyvsp[-1].str_vec);
                (yyval.insert_stmt)->select = (yyvsp[0].select_stmt);           // 注意：select_no_paren 是 $6


				(yyval.insert_stmt)->valuesLine   = (yylsp[0]).first_line;
				(yyval.insert_stmt)->valuesColumn = (yylsp[0]).first_column;
				
				if ((yyvsp[-1].str_vec) && !g_colPos.empty() && !g_colPosMoved) {
					//std::cout << "[BISON] before move, g_colPos.size=" << g_colPos.size() << std::endl;
					(yyval.insert_stmt)->colPos = new std::vector<std::pair<std::string, std::pair<int,int>>>(std::move(g_colPos));
					g_colPosMoved = true;   // 标记已 move
					//std::cout << "[BISON] after move, g_colPos.size=" << g_colPos.size() << std::endl;
				} else {
					(yyval.insert_stmt)->colPos = nullptr;
				}


                (yyval.insert_stmt)->errorLine = (yylsp[-1]).first_line;
                (yyval.insert_stmt)->errorColumn = (yylsp[-1]).first_column;

				//std::cout << "[BISON] exit insert_statement, $$->colPos=" << $$->colPos << std::endl;
					//if ($$->colPos) {
						//std::cout << "[BISON] exit colPos size=" << $$->colPos->size() << std::endl;
					//}
        }
#line 3751 "bison_parser.cpp"
    break;

  case 72: /* opt_column_list: '(' ident_commalist ')'  */
#line 751 "bison_parser.y"
                                        { (yyval.str_vec) = (yyvsp[-1].str_vec);}
#line 3757 "bison_parser.cpp"
    break;

  case 73: /* opt_column_list: %empty  */
#line 752 "bison_parser.y"
                            { (yyval.str_vec) = nullptr; }
#line 3763 "bison_parser.cpp"
    break;

  case 74: /* update_statement: UPDATE table_ref_name_no_alias SET update_clause_commalist opt_where  */
#line 762 "bison_parser.y"
                                                                             {
		(yyval.update_stmt) = new UpdateStatement();
		(yyval.update_stmt)->table = (yyvsp[-3].table);
		(yyval.update_stmt)->updates = (yyvsp[-1].update_vec);
		(yyval.update_stmt)->where = (yyvsp[0].stat);

		(yyval.update_stmt)->errorLine = (yylsp[-3]).first_line;
        (yyval.update_stmt)->errorColumn = (yylsp[-3]).first_column;

		/* 记录 WHERE 节点坐标（用于任何 WHERE 报错） */
		if ((yyvsp[0].stat)) {                              
            (yyval.update_stmt)->whereLine   = (yylsp[0]).first_line;
            (yyval.update_stmt)->whereColumn = (yylsp[0]).first_column;
        }

		/* 仅当 WHERE 是“列 = 值”时才记录等值坐标 */
		if ((yyvsp[0].stat) && (yyvsp[0].stat)->opType == kOpEquals &&
            (yyvsp[0].stat)->stat  && (yyvsp[0].stat)->stat->type  == kStatColumnRef &&
            (yyvsp[0].stat)->stat2 && (yyvsp[0].stat)->stat2->isLiteral()) {
            (yyval.update_stmt)->eqOpLine   = (yylsp[0]).first_line;
            (yyval.update_stmt)->eqOpColumn = (yylsp[0]).first_column;
        }
    }
#line 3791 "bison_parser.cpp"
    break;

  case 75: /* update_clause_commalist: update_clause  */
#line 788 "bison_parser.y"
                              { (yyval.update_vec) = new std::vector<UpdateClause*>(); (yyval.update_vec)->push_back((yyvsp[0].update_t)); }
#line 3797 "bison_parser.cpp"
    break;

  case 76: /* update_clause_commalist: update_clause_commalist ',' update_clause  */
#line 789 "bison_parser.y"
                                                          { (yyvsp[-2].update_vec)->push_back((yyvsp[0].update_t)); (yyval.update_vec) = (yyvsp[-2].update_vec); }
#line 3803 "bison_parser.cpp"
    break;

  case 77: /* update_clause: IDENTIFIER '=' stat  */
#line 793 "bison_parser.y"
                                    {
			(yyval.update_t) = new UpdateClause();
			(yyval.update_t)->column = (yyvsp[-2].stat)->name;
			(yyval.update_t)->value = (yyvsp[0].stat);

			//新增：临时保存行列信息
			(yyval.update_t)->columnLine = (yyvsp[-2].stat)->first_line;
        	(yyval.update_t)->columnCol = (yyvsp[-2].stat)->first_column;
		}
#line 3817 "bison_parser.cpp"
    break;

  case 78: /* select_statement: select_with_paren  */
#line 810 "bison_parser.y"
                {
			(yyval.select_stmt) = (yyvsp[0].select_stmt);
			(yyval.select_stmt)->errorLine = (yylsp[0]).first_line;
			(yyval.select_stmt)->errorColumn = (yylsp[0]).first_column;
		}
#line 3827 "bison_parser.cpp"
    break;

  case 79: /* select_statement: select_no_paren  */
#line 816 "bison_parser.y"
                {
			(yyval.select_stmt) = (yyvsp[0].select_stmt);
			(yyval.select_stmt)->errorLine = (yylsp[0]).first_line;
			(yyval.select_stmt)->errorColumn = (yylsp[0]).first_column;
		}
#line 3837 "bison_parser.cpp"
    break;

  case 80: /* select_statement: select_with_paren set_operator select_paren_or_clause opt_order opt_limit  */
#line 822 "bison_parser.y"
                {
			// TODO: allow multiple unions (through linked list)
			// TODO: capture type of set_operator
			// TODO: might overwrite order and limit of first select here
			(yyval.select_stmt) = (yyvsp[-4].select_stmt);
			(yyval.select_stmt)->unionSelect = (yyvsp[-2].select_stmt);
			(yyval.select_stmt)->order = (yyvsp[-1].order_vec);

			// Limit could have been set by TOP.
			if ((yyvsp[0].limit) != nullptr) {
				delete (yyval.select_stmt)->limit;
				(yyval.select_stmt)->limit = (yyvsp[0].limit);
			}

			(yyval.select_stmt)->errorLine = (yylsp[-4]).first_line;
			(yyval.select_stmt)->errorColumn = (yylsp[-4]).first_column;
		}
#line 3859 "bison_parser.cpp"
    break;

  case 81: /* select_with_paren: '(' select_no_paren ')'  */
#line 842 "bison_parser.y"
                                        { (yyval.select_stmt) = (yyvsp[-1].select_stmt); }
#line 3865 "bison_parser.cpp"
    break;

  case 82: /* select_with_paren: '(' select_with_paren ')'  */
#line 843 "bison_parser.y"
                                          { (yyval.select_stmt) = (yyvsp[-1].select_stmt); }
#line 3871 "bison_parser.cpp"
    break;

  case 85: /* select_no_paren: select_clause opt_order opt_limit  */
#line 853 "bison_parser.y"
                {
			(yyval.select_stmt) = (yyvsp[-2].select_stmt);
			(yyval.select_stmt)->order = (yyvsp[-1].order_vec);

			// Limit could have been set by TOP.
			if ((yyvsp[0].limit) != nullptr) {
				delete (yyval.select_stmt)->limit;
				(yyval.select_stmt)->limit = (yyvsp[0].limit);
			}

			(yyval.select_stmt)->errorLine = (yylsp[-2]).first_line;
			(yyval.select_stmt)->errorColumn = (yylsp[-2]).first_column;
		}
#line 3889 "bison_parser.cpp"
    break;

  case 86: /* select_no_paren: select_clause set_operator select_paren_or_clause opt_order opt_limit  */
#line 867 "bison_parser.y"
                {
			// TODO: allow multiple unions (through linked list)
			// TODO: capture type of set_operator
			// TODO: might overwrite order and limit of first select here
			(yyval.select_stmt) = (yyvsp[-4].select_stmt);
			(yyval.select_stmt)->unionSelect = (yyvsp[-2].select_stmt);
			(yyval.select_stmt)->order = (yyvsp[-1].order_vec);

			// Limit could have been set by TOP.
			if ((yyvsp[0].limit) != nullptr) {
				delete (yyval.select_stmt)->limit;
				(yyval.select_stmt)->limit = (yyvsp[0].limit);
			}

			(yyval.select_stmt)->errorLine = (yylsp[-4]).first_line;
			(yyval.select_stmt)->errorColumn = (yylsp[-4]).first_column;
		}
#line 3911 "bison_parser.cpp"
    break;

  case 93: /* select_clause: SELECT opt_top opt_distinct select_list opt_from_clause opt_where opt_group  */
#line 902 "bison_parser.y"
                                                                                            {
			(yyval.select_stmt) = new SelectStatement();
			(yyval.select_stmt)->limit = (yyvsp[-5].limit);
			(yyval.select_stmt)->selectDistinct = (yyvsp[-4].bval);
			(yyval.select_stmt)->selectList = (yyvsp[-3].stat_vec);
			(yyval.select_stmt)->fromTable = (yyvsp[-2].table);
			(yyval.select_stmt)->whereClause = (yyvsp[-1].stat);
			(yyval.select_stmt)->groupBy = (yyvsp[0].group_t);

			if ((yyvsp[-1].stat)) {  // $6 是 opt_where
            (yyval.select_stmt)->whereClause = (yyvsp[-1].stat);
            (yyval.select_stmt)->whereLine = (yylsp[-1]).first_line;
            (yyval.select_stmt)->whereColumn = (yylsp[-1]).first_column;
        }
		}
#line 3931 "bison_parser.cpp"
    break;

  case 94: /* opt_distinct: DISTINCT  */
#line 920 "bison_parser.y"
                         { (yyval.bval) = true; }
#line 3937 "bison_parser.cpp"
    break;

  case 95: /* opt_distinct: %empty  */
#line 921 "bison_parser.y"
                            { (yyval.bval) = false; }
#line 3943 "bison_parser.cpp"
    break;

  case 97: /* opt_from_clause: from_clause  */
#line 929 "bison_parser.y"
                     { (yyval.table) = (yyvsp[0].table); }
#line 3949 "bison_parser.cpp"
    break;

  case 98: /* opt_from_clause: %empty  */
#line 930 "bison_parser.y"
                     { (yyval.table) = nullptr; }
#line 3955 "bison_parser.cpp"
    break;

  case 99: /* from_clause: FROM table_ref  */
#line 933 "bison_parser.y"
                               { (yyval.table) = (yyvsp[0].table); }
#line 3961 "bison_parser.cpp"
    break;

  case 100: /* opt_where: WHERE stat  */
#line 938 "bison_parser.y"
                           { (yyval.stat) = (yyvsp[0].stat); }
#line 3967 "bison_parser.cpp"
    break;

  case 101: /* opt_where: %empty  */
#line 939 "bison_parser.y"
                            { (yyval.stat) = nullptr; }
#line 3973 "bison_parser.cpp"
    break;

  case 102: /* opt_group: GROUP BY stat_list opt_having  */
#line 943 "bison_parser.y"
                                              {
			(yyval.group_t) = new GroupByDescription();
			(yyval.group_t)->columns = (yyvsp[-1].stat_vec);
			(yyval.group_t)->having = (yyvsp[0].stat);
		}
#line 3983 "bison_parser.cpp"
    break;

  case 103: /* opt_group: %empty  */
#line 948 "bison_parser.y"
                            { (yyval.group_t) = nullptr; }
#line 3989 "bison_parser.cpp"
    break;

  case 104: /* opt_having: HAVING stat  */
#line 952 "bison_parser.y"
                            { (yyval.stat) = (yyvsp[0].stat); }
#line 3995 "bison_parser.cpp"
    break;

  case 105: /* opt_having: %empty  */
#line 953 "bison_parser.y"
                            { (yyval.stat) = nullptr; }
#line 4001 "bison_parser.cpp"
    break;

  case 106: /* opt_order: ORDER BY order_list  */
#line 956 "bison_parser.y"
                                    { (yyval.order_vec) = (yyvsp[0].order_vec); }
#line 4007 "bison_parser.cpp"
    break;

  case 107: /* opt_order: %empty  */
#line 957 "bison_parser.y"
                            { (yyval.order_vec) = nullptr; }
#line 4013 "bison_parser.cpp"
    break;

  case 108: /* order_list: order_desc  */
#line 961 "bison_parser.y"
                           { (yyval.order_vec) = new std::vector<OrderDescription*>(); (yyval.order_vec)->push_back((yyvsp[0].order)); }
#line 4019 "bison_parser.cpp"
    break;

  case 109: /* order_list: order_list ',' order_desc  */
#line 962 "bison_parser.y"
                                          { (yyvsp[-2].order_vec)->push_back((yyvsp[0].order)); (yyval.order_vec) = (yyvsp[-2].order_vec); }
#line 4025 "bison_parser.cpp"
    break;

  case 110: /* order_desc: stat opt_order_type  */
#line 966 "bison_parser.y"
                                    { (yyval.order) = new OrderDescription((yyvsp[0].order_type), (yyvsp[-1].stat)); }
#line 4031 "bison_parser.cpp"
    break;

  case 111: /* opt_order_type: ASC  */
#line 970 "bison_parser.y"
                    { (yyval.order_type) = kOrderAsc; }
#line 4037 "bison_parser.cpp"
    break;

  case 112: /* opt_order_type: DESC  */
#line 971 "bison_parser.y"
                     { (yyval.order_type) = kOrderDesc; }
#line 4043 "bison_parser.cpp"
    break;

  case 113: /* opt_order_type: %empty  */
#line 972 "bison_parser.y"
                            { (yyval.order_type) = kOrderAsc; }
#line 4049 "bison_parser.cpp"
    break;

  case 114: /* opt_top: TOP int_literal  */
#line 978 "bison_parser.y"
                                { (yyval.limit) = new LimitDescription((yyvsp[0].stat)->ival, kNoOffset); delete (yyvsp[0].stat); }
#line 4055 "bison_parser.cpp"
    break;

  case 115: /* opt_top: %empty  */
#line 979 "bison_parser.y"
                            { (yyval.limit) = nullptr; }
#line 4061 "bison_parser.cpp"
    break;

  case 116: /* opt_limit: LIMIT int_literal  */
#line 983 "bison_parser.y"
                                  { (yyval.limit) = new LimitDescription((yyvsp[0].stat)->ival, kNoOffset); delete (yyvsp[0].stat); }
#line 4067 "bison_parser.cpp"
    break;

  case 117: /* opt_limit: LIMIT int_literal OFFSET int_literal  */
#line 984 "bison_parser.y"
                                                     { (yyval.limit) = new LimitDescription((yyvsp[-2].stat)->ival, (yyvsp[0].stat)->ival); delete (yyvsp[-2].stat); delete (yyvsp[0].stat); }
#line 4073 "bison_parser.cpp"
    break;

  case 118: /* opt_limit: OFFSET int_literal  */
#line 985 "bison_parser.y"
                                   { (yyval.limit) = new LimitDescription(kNoLimit, (yyvsp[0].stat)->ival); delete (yyvsp[0].stat); }
#line 4079 "bison_parser.cpp"
    break;

  case 119: /* opt_limit: LIMIT ALL  */
#line 986 "bison_parser.y"
                          { (yyval.limit) = nullptr; }
#line 4085 "bison_parser.cpp"
    break;

  case 120: /* opt_limit: LIMIT NULL  */
#line 987 "bison_parser.y"
                           { (yyval.limit) = nullptr;  }
#line 4091 "bison_parser.cpp"
    break;

  case 121: /* opt_limit: LIMIT ALL OFFSET int_literal  */
#line 988 "bison_parser.y"
                                             { (yyval.limit) = new LimitDescription(kNoLimit, (yyvsp[0].stat)->ival); delete (yyvsp[0].stat); }
#line 4097 "bison_parser.cpp"
    break;

  case 122: /* opt_limit: LIMIT NULL OFFSET int_literal  */
#line 989 "bison_parser.y"
                                              { (yyval.limit) = new LimitDescription(kNoLimit, (yyvsp[0].stat)->ival); delete (yyvsp[0].stat); }
#line 4103 "bison_parser.cpp"
    break;

  case 123: /* opt_limit: %empty  */
#line 990 "bison_parser.y"
                            { (yyval.limit) = nullptr; }
#line 4109 "bison_parser.cpp"
    break;

  case 124: /* stat_list: stat_alias  */
#line 997 "bison_parser.y"
                           { (yyval.stat_vec) = new std::vector<Stat*>(); (yyval.stat_vec)->push_back((yyvsp[0].stat)); }
#line 4115 "bison_parser.cpp"
    break;

  case 125: /* stat_list: stat_list ',' stat_alias  */
#line 998 "bison_parser.y"
                                         { (yyvsp[-2].stat_vec)->push_back((yyvsp[0].stat)); (yyval.stat_vec) = (yyvsp[-2].stat_vec); }
#line 4121 "bison_parser.cpp"
    break;

  case 126: /* literal_list: literal  */
#line 1002 "bison_parser.y"
                        { 
			(yyval.stat_vec) = new std::vector<Stat*>(); 
			(yyval.stat_vec)->push_back((yyvsp[0].stat)); 

			//9.13
			g_valuePos.emplace_back((yylsp[0]).first_line, (yylsp[0]).first_column);

			//9.14
			// 记录值的位置
			if ((yyvsp[0].stat)) {
				(yyvsp[0].stat)->first_line = (yylsp[0]).first_line;
				(yyvsp[0].stat)->first_column = (yylsp[0]).first_column;
			}

			}
#line 4141 "bison_parser.cpp"
    break;

  case 127: /* literal_list: literal_list ',' literal  */
#line 1017 "bison_parser.y"
                                         { 
		(yyvsp[-2].stat_vec)->push_back((yyvsp[0].stat)); 
		(yyval.stat_vec) = (yyvsp[-2].stat_vec); 

		//9.13
		g_valuePos.emplace_back((yylsp[0]).first_line, (yylsp[0]).first_column);

		//9.14
		// 记录值的位置
		if ((yyvsp[0].stat)) {
			(yyvsp[0].stat)->first_line = (yylsp[0]).first_line;
			(yyvsp[0].stat)->first_column = (yylsp[0]).first_column;
		}
		}
#line 4160 "bison_parser.cpp"
    break;

  case 128: /* stat_alias: stat opt_alias  */
#line 1034 "bison_parser.y"
                               {
			(yyval.stat) = (yyvsp[-1].stat);
			if ((yyvsp[0].alias_t)) {
				(yyval.stat)->alias = _strdup((yyvsp[0].alias_t)->name);
				delete (yyvsp[0].alias_t);
			}
		}
#line 4172 "bison_parser.cpp"
    break;

  case 134: /* operand: '(' stat ')'  */
#line 1052 "bison_parser.y"
                             { (yyval.stat) = (yyvsp[-1].stat); }
#line 4178 "bison_parser.cpp"
    break;

  case 143: /* operand: '(' select_no_paren ')'  */
#line 1061 "bison_parser.y"
                                        { (yyval.stat) = Stat::makeSelect((yyvsp[-1].select_stmt)); }
#line 4184 "bison_parser.cpp"
    break;

  case 146: /* unary_stat: '-' operand  */
#line 1070 "bison_parser.y"
                            { (yyval.stat) = Stat::makeOpUnary(kOpUnaryMinus, (yyvsp[0].stat)); }
#line 4190 "bison_parser.cpp"
    break;

  case 147: /* unary_stat: NOT operand  */
#line 1071 "bison_parser.y"
                            { (yyval.stat) = Stat::makeOpUnary(kOpNot, (yyvsp[0].stat)); }
#line 4196 "bison_parser.cpp"
    break;

  case 148: /* unary_stat: operand ISNULL  */
#line 1072 "bison_parser.y"
                               { (yyval.stat) = Stat::makeOpUnary(kOpIsNull, (yyvsp[-1].stat)); }
#line 4202 "bison_parser.cpp"
    break;

  case 149: /* unary_stat: operand IS NULL  */
#line 1073 "bison_parser.y"
                                { (yyval.stat) = Stat::makeOpUnary(kOpIsNull, (yyvsp[-2].stat)); }
#line 4208 "bison_parser.cpp"
    break;

  case 150: /* unary_stat: operand IS NOT NULL  */
#line 1074 "bison_parser.y"
                                    { (yyval.stat) = Stat::makeOpUnary(kOpNot, Stat::makeOpUnary(kOpIsNull, (yyvsp[-3].stat))); }
#line 4214 "bison_parser.cpp"
    break;

  case 152: /* binary_stat: operand '-' operand  */
#line 1079 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpMinus, (yyvsp[0].stat)); }
#line 4220 "bison_parser.cpp"
    break;

  case 153: /* binary_stat: operand '+' operand  */
#line 1080 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpPlus, (yyvsp[0].stat)); }
#line 4226 "bison_parser.cpp"
    break;

  case 154: /* binary_stat: operand '/' operand  */
#line 1081 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpSlash, (yyvsp[0].stat)); }
#line 4232 "bison_parser.cpp"
    break;

  case 155: /* binary_stat: operand '*' operand  */
#line 1082 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpAsterisk, (yyvsp[0].stat)); }
#line 4238 "bison_parser.cpp"
    break;

  case 156: /* binary_stat: operand '%' operand  */
#line 1083 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpPercentage, (yyvsp[0].stat)); }
#line 4244 "bison_parser.cpp"
    break;

  case 157: /* binary_stat: operand '^' operand  */
#line 1084 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpCaret, (yyvsp[0].stat)); }
#line 4250 "bison_parser.cpp"
    break;

  case 158: /* binary_stat: operand LIKE operand  */
#line 1085 "bison_parser.y"
                                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpLike, (yyvsp[0].stat)); }
#line 4256 "bison_parser.cpp"
    break;

  case 159: /* binary_stat: operand NOT LIKE operand  */
#line 1086 "bison_parser.y"
                                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-3].stat), kOpNotLike, (yyvsp[0].stat)); }
#line 4262 "bison_parser.cpp"
    break;

  case 160: /* binary_stat: operand ILIKE operand  */
#line 1087 "bison_parser.y"
                                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpILike, (yyvsp[0].stat)); }
#line 4268 "bison_parser.cpp"
    break;

  case 161: /* binary_stat: operand CONCAT operand  */
#line 1088 "bison_parser.y"
                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpConcat, (yyvsp[0].stat)); }
#line 4274 "bison_parser.cpp"
    break;

  case 162: /* logic_stat: stat AND stat  */
#line 1092 "bison_parser.y"
                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpAnd, (yyvsp[0].stat)); }
#line 4280 "bison_parser.cpp"
    break;

  case 163: /* logic_stat: stat OR stat  */
#line 1093 "bison_parser.y"
                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpOr, (yyvsp[0].stat)); }
#line 4286 "bison_parser.cpp"
    break;

  case 164: /* in_stat: operand IN '(' stat_list ')'  */
#line 1097 "bison_parser.y"
                                                                { (yyval.stat) = Stat::makeInOperator((yyvsp[-4].stat), (yyvsp[-1].stat_vec)); }
#line 4292 "bison_parser.cpp"
    break;

  case 165: /* in_stat: operand NOT IN '(' stat_list ')'  */
#line 1098 "bison_parser.y"
                                                                { (yyval.stat) = Stat::makeOpUnary(kOpNot, Stat::makeInOperator((yyvsp[-5].stat), (yyvsp[-1].stat_vec))); }
#line 4298 "bison_parser.cpp"
    break;

  case 166: /* in_stat: operand IN '(' select_no_paren ')'  */
#line 1099 "bison_parser.y"
                                                                { (yyval.stat) = Stat::makeInOperator((yyvsp[-4].stat), (yyvsp[-1].select_stmt)); }
#line 4304 "bison_parser.cpp"
    break;

  case 167: /* in_stat: operand NOT IN '(' select_no_paren ')'  */
#line 1100 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpUnary(kOpNot, Stat::makeInOperator((yyvsp[-5].stat), (yyvsp[-1].select_stmt))); }
#line 4310 "bison_parser.cpp"
    break;

  case 168: /* case_stat: CASE stat case_list END  */
#line 1106 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeCase((yyvsp[-2].stat), (yyvsp[-1].stat), nullptr); }
#line 4316 "bison_parser.cpp"
    break;

  case 169: /* case_stat: CASE stat case_list ELSE stat END  */
#line 1107 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeCase((yyvsp[-4].stat), (yyvsp[-3].stat), (yyvsp[-1].stat)); }
#line 4322 "bison_parser.cpp"
    break;

  case 170: /* case_stat: CASE case_list END  */
#line 1108 "bison_parser.y"
                                                                { (yyval.stat) = Stat::makeCase(nullptr, (yyvsp[-1].stat), nullptr); }
#line 4328 "bison_parser.cpp"
    break;

  case 171: /* case_stat: CASE case_list ELSE stat END  */
#line 1109 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeCase(nullptr, (yyvsp[-3].stat), (yyvsp[-1].stat)); }
#line 4334 "bison_parser.cpp"
    break;

  case 172: /* case_list: WHEN stat THEN stat  */
#line 1113 "bison_parser.y"
                                                 { (yyval.stat) = Stat::makeCaseList(Stat::makeCaseListElement((yyvsp[-2].stat), (yyvsp[0].stat))); }
#line 4340 "bison_parser.cpp"
    break;

  case 173: /* case_list: case_list WHEN stat THEN stat  */
#line 1114 "bison_parser.y"
                                                 { (yyval.stat) = Stat::caseListAppend((yyvsp[-4].stat), Stat::makeCaseListElement((yyvsp[-2].stat), (yyvsp[0].stat))); }
#line 4346 "bison_parser.cpp"
    break;

  case 174: /* exists_stat: EXISTS '(' select_no_paren ')'  */
#line 1118 "bison_parser.y"
                                               { (yyval.stat) = Stat::makeExists((yyvsp[-1].select_stmt)); }
#line 4352 "bison_parser.cpp"
    break;

  case 175: /* exists_stat: NOT EXISTS '(' select_no_paren ')'  */
#line 1119 "bison_parser.y"
                                                   { (yyval.stat) = Stat::makeOpUnary(kOpNot, Stat::makeExists((yyvsp[-1].select_stmt))); }
#line 4358 "bison_parser.cpp"
    break;

  case 176: /* comp_stat: operand '=' operand  */
#line 1123 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpEquals, (yyvsp[0].stat)); }
#line 4364 "bison_parser.cpp"
    break;

  case 177: /* comp_stat: operand EQUALS operand  */
#line 1124 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpEquals, (yyvsp[0].stat)); }
#line 4370 "bison_parser.cpp"
    break;

  case 178: /* comp_stat: operand NOTEQUALS operand  */
#line 1125 "bison_parser.y"
                                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpNotEquals, (yyvsp[0].stat)); }
#line 4376 "bison_parser.cpp"
    break;

  case 179: /* comp_stat: operand '<' operand  */
#line 1126 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpLess, (yyvsp[0].stat)); }
#line 4382 "bison_parser.cpp"
    break;

  case 180: /* comp_stat: operand '>' operand  */
#line 1127 "bison_parser.y"
                                                        { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpGreater, (yyvsp[0].stat)); }
#line 4388 "bison_parser.cpp"
    break;

  case 181: /* comp_stat: operand LESSEQ operand  */
#line 1128 "bison_parser.y"
                                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpLessEq, (yyvsp[0].stat)); }
#line 4394 "bison_parser.cpp"
    break;

  case 182: /* comp_stat: operand GREATEREQ operand  */
#line 1129 "bison_parser.y"
                                                { (yyval.stat) = Stat::makeOpBinary((yyvsp[-2].stat), kOpGreaterEq, (yyvsp[0].stat)); }
#line 4400 "bison_parser.cpp"
    break;

  case 183: /* function_stat: IDENTIFIER '(' ')'  */
#line 1133 "bison_parser.y"
                                  { (yyval.stat) = Stat::makeFunctionRef((yyvsp[-2].stat)->name, new std::vector<Stat*>(), false); }
#line 4406 "bison_parser.cpp"
    break;

  case 184: /* function_stat: IDENTIFIER '(' opt_distinct stat_list ')'  */
#line 1134 "bison_parser.y"
                                                         { (yyval.stat) = Stat::makeFunctionRef((yyvsp[-4].stat)->name, (yyvsp[-1].stat_vec), (yyvsp[-2].bval)); }
#line 4412 "bison_parser.cpp"
    break;

  case 185: /* extract_stat: EXTRACT '(' datetime_field FROM stat ')'  */
#line 1138 "bison_parser.y"
                                                     { (yyval.stat) = Stat::makeExtract((yyvsp[-3].datetime_field), (yyvsp[-1].stat)); }
#line 4418 "bison_parser.cpp"
    break;

  case 186: /* datetime_field: SECOND  */
#line 1142 "bison_parser.y"
               { (yyval.datetime_field) = kDatetimeSecond; }
#line 4424 "bison_parser.cpp"
    break;

  case 187: /* datetime_field: MINUTE  */
#line 1143 "bison_parser.y"
               { (yyval.datetime_field) = kDatetimeMinute; }
#line 4430 "bison_parser.cpp"
    break;

  case 188: /* datetime_field: HOUR  */
#line 1144 "bison_parser.y"
             { (yyval.datetime_field) = kDatetimeHour; }
#line 4436 "bison_parser.cpp"
    break;

  case 189: /* datetime_field: DAY  */
#line 1145 "bison_parser.y"
            { (yyval.datetime_field) = kDatetimeDay; }
#line 4442 "bison_parser.cpp"
    break;

  case 190: /* datetime_field: MONTH  */
#line 1146 "bison_parser.y"
              { (yyval.datetime_field) = kDatetimeMonth; }
#line 4448 "bison_parser.cpp"
    break;

  case 191: /* datetime_field: YEAR  */
#line 1147 "bison_parser.y"
             { (yyval.datetime_field) = kDatetimeYear; }
#line 4454 "bison_parser.cpp"
    break;

  case 192: /* array_stat: ARRAY '[' stat_list ']'  */
#line 1150 "bison_parser.y"
                                        { (yyval.stat) = Stat::makeArray((yyvsp[-1].stat_vec)); }
#line 4460 "bison_parser.cpp"
    break;

  case 193: /* array_index: operand '[' int_literal ']'  */
#line 1154 "bison_parser.y"
                                            { (yyval.stat) = Stat::makeArrayIndex((yyvsp[-3].stat), (yyvsp[-1].stat)->ival); }
#line 4466 "bison_parser.cpp"
    break;

  case 194: /* between_stat: operand BETWEEN operand AND operand  */
#line 1158 "bison_parser.y"
                                                    { (yyval.stat) = Stat::makeBetween((yyvsp[-4].stat), (yyvsp[-2].stat), (yyvsp[0].stat)); }
#line 4472 "bison_parser.cpp"
    break;

  case 195: /* column_name: IDENTIFIER  */
#line 1162 "bison_parser.y"
               { (yyval.stat) = (yyvsp[0].stat); }
#line 4478 "bison_parser.cpp"
    break;

  case 196: /* column_name: IDENTIFIER '.' IDENTIFIER  */
#line 1164 "bison_parser.y"
                              {
        (yyval.stat) = Stat::makeColumnRef((yyvsp[-2].stat)->name, (yyvsp[0].stat)->name);
        (yyval.stat)->first_line   = (yyvsp[-2].stat)->first_line;
        (yyval.stat)->first_column = (yyvsp[-2].stat)->first_column;
    }
#line 4488 "bison_parser.cpp"
    break;

  case 197: /* column_name: '*'  */
#line 1170 "bison_parser.y"
        { (yyval.stat) = Stat::makeStar(); }
#line 4494 "bison_parser.cpp"
    break;

  case 198: /* column_name: IDENTIFIER '.' '*'  */
#line 1172 "bison_parser.y"
                       {
        (yyval.stat) = Stat::makeStar((yyvsp[-2].stat)->name);
        (yyval.stat)->first_line   = (yyvsp[-2].stat)->first_line;
        (yyval.stat)->first_column = (yyvsp[-2].stat)->first_column;
    }
#line 4504 "bison_parser.cpp"
    break;

  case 204: /* string_literal: STRING  */
#line 1188 "bison_parser.y"
                       { (yyval.stat) = Stat::makeLiteral((yyvsp[0].sval)); }
#line 4510 "bison_parser.cpp"
    break;

  case 205: /* bool_literal: TRUE  */
#line 1192 "bison_parser.y"
                     { (yyval.stat) = Stat::makeLiteral(true); }
#line 4516 "bison_parser.cpp"
    break;

  case 206: /* bool_literal: FALSE  */
#line 1193 "bison_parser.y"
                      { (yyval.stat) = Stat::makeLiteral(false); }
#line 4522 "bison_parser.cpp"
    break;

  case 207: /* num_literal: FLOATVAL  */
#line 1197 "bison_parser.y"
                         { (yyval.stat) = Stat::makeLiteral((yyvsp[0].fval)); }
#line 4528 "bison_parser.cpp"
    break;

  case 209: /* int_literal: INTVAL  */
#line 1202 "bison_parser.y"
                       { (yyval.stat) = Stat::makeLiteral((yyvsp[0].ival)); }
#line 4534 "bison_parser.cpp"
    break;

  case 210: /* null_literal: NULL  */
#line 1206 "bison_parser.y"
                     { (yyval.stat) = Stat::makeNullLiteral(); }
#line 4540 "bison_parser.cpp"
    break;

  case 211: /* param_stat: '?'  */
#line 1210 "bison_parser.y"
                    {
			(yyval.stat) = Stat::makeParameter(yylloc.total_column);
			(yyval.stat)->ival2 = yyloc.param_list.size();
			yyloc.param_list.push_back((yyval.stat));
		}
#line 4550 "bison_parser.cpp"
    break;

  case 213: /* table_ref: table_ref_commalist ',' table_ref_atomic  */
#line 1223 "bison_parser.y"
                                                         {
			(yyvsp[-2].table_vec)->push_back((yyvsp[0].table));
			auto tbl = new TableRef(kTableCrossProduct);
			tbl->list = (yyvsp[-2].table_vec);
			(yyval.table) = tbl;
		}
#line 4561 "bison_parser.cpp"
    break;

  case 217: /* nonjoin_table_ref_atomic: '(' select_statement ')' opt_table_alias  */
#line 1239 "bison_parser.y"
                                                         {
			auto tbl = new TableRef(kTableSelect);
			tbl->select = (yyvsp[-2].select_stmt);
			tbl->alias = (yyvsp[0].alias_t);
			(yyval.table) = tbl;
		}
#line 4572 "bison_parser.cpp"
    break;

  case 218: /* table_ref_commalist: table_ref_atomic  */
#line 1248 "bison_parser.y"
                                 { (yyval.table_vec) = new std::vector<TableRef*>(); (yyval.table_vec)->push_back((yyvsp[0].table)); }
#line 4578 "bison_parser.cpp"
    break;

  case 219: /* table_ref_commalist: table_ref_commalist ',' table_ref_atomic  */
#line 1249 "bison_parser.y"
                                                         { (yyvsp[-2].table_vec)->push_back((yyvsp[0].table)); (yyval.table_vec) = (yyvsp[-2].table_vec); }
#line 4584 "bison_parser.cpp"
    break;

  case 220: /* table_ref_name: table_name opt_table_alias  */
#line 1254 "bison_parser.y"
                                           {
			auto tbl = new TableRef(kTableName);
			tbl->schema = (yyvsp[-1].table_name).schema;
			tbl->name = (yyvsp[-1].table_name).name;
			tbl->alias = (yyvsp[0].alias_t);
			(yyval.table) = tbl;
		}
#line 4596 "bison_parser.cpp"
    break;

  case 221: /* table_ref_name_no_alias: table_name  */
#line 1265 "bison_parser.y"
                           {
			(yyval.table) = new TableRef(kTableName);
			(yyval.table)->schema = (yyvsp[0].table_name).schema;
			(yyval.table)->name = (yyvsp[0].table_name).name;
		}
#line 4606 "bison_parser.cpp"
    break;

  case 222: /* table_name: IDENTIFIER  */
#line 1274 "bison_parser.y"
                                          { (yyval.table_name).schema = nullptr; (yyval.table_name).name = (yyvsp[0].stat)->name;}
#line 4612 "bison_parser.cpp"
    break;

  case 223: /* table_name: IDENTIFIER '.' IDENTIFIER  */
#line 1275 "bison_parser.y"
                                          { (yyval.table_name).schema = (yyvsp[-2].stat)->name; (yyval.table_name).name = (yyvsp[0].stat)->name; }
#line 4618 "bison_parser.cpp"
    break;

  case 225: /* table_alias: AS IDENTIFIER '(' ident_commalist ')'  */
#line 1281 "bison_parser.y"
                                                      { (yyval.alias_t) = new Alias((yyvsp[-3].stat)->name, (yyvsp[-1].str_vec)); }
#line 4624 "bison_parser.cpp"
    break;

  case 227: /* opt_table_alias: %empty  */
#line 1287 "bison_parser.y"
                            { (yyval.alias_t) = nullptr; }
#line 4630 "bison_parser.cpp"
    break;

  case 228: /* alias: AS IDENTIFIER  */
#line 1291 "bison_parser.y"
                              { (yyval.alias_t) = new Alias((yyvsp[0].stat)->name); }
#line 4636 "bison_parser.cpp"
    break;

  case 229: /* alias: IDENTIFIER  */
#line 1292 "bison_parser.y"
                           { (yyval.alias_t) = new Alias((yyvsp[0].stat)->name); }
#line 4642 "bison_parser.cpp"
    break;

  case 231: /* opt_alias: %empty  */
#line 1298 "bison_parser.y"
                            { (yyval.alias_t) = nullptr; }
#line 4648 "bison_parser.cpp"
    break;

  case 232: /* join_clause: table_ref_atomic NATURAL JOIN nonjoin_table_ref_atomic  */
#line 1307 "bison_parser.y"
                {
			(yyval.table) = new TableRef(kTableJoin);
			(yyval.table)->join = new JoinDefinition();
			(yyval.table)->join->type = kJoinNatural;
			(yyval.table)->join->left = (yyvsp[-3].table);
			(yyval.table)->join->right = (yyvsp[0].table);
		}
#line 4660 "bison_parser.cpp"
    break;

  case 233: /* join_clause: table_ref_atomic opt_join_type JOIN table_ref_atomic ON join_condition  */
#line 1315 "bison_parser.y"
                {
			(yyval.table) = new TableRef(kTableJoin);
			(yyval.table)->join = new JoinDefinition();
			(yyval.table)->join->type = (JoinType) (yyvsp[-4].uval);
			(yyval.table)->join->left = (yyvsp[-5].table);
			(yyval.table)->join->right = (yyvsp[-2].table);
			(yyval.table)->join->condition = (yyvsp[0].stat);
		}
#line 4673 "bison_parser.cpp"
    break;

  case 234: /* join_clause: table_ref_atomic opt_join_type JOIN table_ref_atomic USING '(' column_name ')'  */
#line 1325 "bison_parser.y"
                {
			(yyval.table) = new TableRef(kTableJoin);
			(yyval.table)->join = new JoinDefinition();
			(yyval.table)->join->type = (JoinType) (yyvsp[-6].uval);
			(yyval.table)->join->left = (yyvsp[-7].table);
			(yyval.table)->join->right = (yyvsp[-4].table);
			auto left_col = Stat::makeColumnRef(_strdup((yyvsp[-1].stat)->name));
			if ((yyvsp[-1].stat)->alias != nullptr) left_col->alias = _strdup((yyvsp[-1].stat)->alias);
			if ((yyvsp[-7].table)->getName() != nullptr) left_col->table = _strdup((yyvsp[-7].table)->getName());
			auto right_col = Stat::makeColumnRef(_strdup((yyvsp[-1].stat)->name));
			if ((yyvsp[-1].stat)->alias != nullptr) right_col->alias = _strdup((yyvsp[-1].stat)->alias);
			if ((yyvsp[-4].table)->getName() != nullptr) right_col->table = _strdup((yyvsp[-4].table)->getName());
			(yyval.table)->join->condition = Stat::makeOpBinary(left_col, kOpEquals, right_col);
			delete (yyvsp[-1].stat);
		}
#line 4693 "bison_parser.cpp"
    break;

  case 235: /* opt_join_type: INNER  */
#line 1343 "bison_parser.y"
                                { (yyval.uval) = kJoinInner; }
#line 4699 "bison_parser.cpp"
    break;

  case 236: /* opt_join_type: LEFT OUTER  */
#line 1344 "bison_parser.y"
                                { (yyval.uval) = kJoinLeft; }
#line 4705 "bison_parser.cpp"
    break;

  case 237: /* opt_join_type: LEFT  */
#line 1345 "bison_parser.y"
                                { (yyval.uval) = kJoinLeft; }
#line 4711 "bison_parser.cpp"
    break;

  case 238: /* opt_join_type: RIGHT OUTER  */
#line 1346 "bison_parser.y"
                                { (yyval.uval) = kJoinRight; }
#line 4717 "bison_parser.cpp"
    break;

  case 239: /* opt_join_type: RIGHT  */
#line 1347 "bison_parser.y"
                                { (yyval.uval) = kJoinRight; }
#line 4723 "bison_parser.cpp"
    break;

  case 240: /* opt_join_type: FULL OUTER  */
#line 1348 "bison_parser.y"
                                { (yyval.uval) = kJoinFull; }
#line 4729 "bison_parser.cpp"
    break;

  case 241: /* opt_join_type: OUTER  */
#line 1349 "bison_parser.y"
                                { (yyval.uval) = kJoinFull; }
#line 4735 "bison_parser.cpp"
    break;

  case 242: /* opt_join_type: FULL  */
#line 1350 "bison_parser.y"
                                { (yyval.uval) = kJoinFull; }
#line 4741 "bison_parser.cpp"
    break;

  case 243: /* opt_join_type: CROSS  */
#line 1351 "bison_parser.y"
                                { (yyval.uval) = kJoinCross; }
#line 4747 "bison_parser.cpp"
    break;

  case 244: /* opt_join_type: %empty  */
#line 1352 "bison_parser.y"
                                        { (yyval.uval) = kJoinInner; }
#line 4753 "bison_parser.cpp"
    break;

  case 246: /* ident_commalist: IDENTIFIER  */
#line 1368 "bison_parser.y"
                           { 
			//std::cout << "[BISON] ident_commalist base case, push " << $1->name << std::endl;
			(yyval.str_vec) = new std::vector<char*>(); 
			(yyval.str_vec)->push_back((yyvsp[0].stat)->name); 
			
			g_colPos.emplace_back((yyvsp[0].stat)->name, std::make_pair((yylsp[0]).first_line, (yylsp[0]).first_column));


			}
#line 4767 "bison_parser.cpp"
    break;

  case 247: /* ident_commalist: ident_commalist ',' IDENTIFIER  */
#line 1377 "bison_parser.y"
                                               { 
		//std::cout << "[BISON] ident_commalist recursive, push " << $3->name << std::endl;
		(yyvsp[-2].str_vec)->push_back((yyvsp[0].stat)->name); 
		(yyval.str_vec) = (yyvsp[-2].str_vec); 

		g_colPos.emplace_back((yyvsp[0].stat)->name, std::make_pair((yylsp[0]).first_line, (yylsp[0]).first_column));
	}
#line 4779 "bison_parser.cpp"
    break;


#line 4783 "bison_parser.cpp"

        default: break;
      }
    if (yychar_backup != yychar)
      YY_LAC_DISCARD ("yychar change");
  }
  /* User semantic actions sometimes alter yychar, and that requires
     that yytoken be updated with the new translation.  We take the
     approach of translating immediately before every use of yytoken.
     One alternative is translating here after every semantic action,
     but that translation would be missed if the semantic action invokes
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
     incorrect destructor might then be invoked immediately.  In the
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
     to an incorrect destructor call or verbose syntax error message
     before the lookahead is translated.  */
  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);

  YYPOPSTACK (yylen);
  yylen = 0;

  *++yyvsp = yyval;
  *++yylsp = yyloc;

  /* Now 'shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */
  {
    const int yylhs = yyr1[yyn] - YYNTOKENS;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }

  goto yynewstate;


/*--------------------------------------.
| yyerrlab -- here on detecting error.  |
`--------------------------------------*/
yyerrlab:
  /* Make sure we have latest lookahead translation.  See comments at
     user semantic actions for why this is necessary.  */
  yytoken = yychar == SQL_MENT_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
      {
        yypcontext_t yyctx
          = {yyssp, yyesa, &yyes, &yyes_capacity, yytoken, &yylloc};
        char const *yymsgp = YY_("syntax error");
        int yysyntax_error_status;
        if (yychar != SQL_MENT_EMPTY)
          YY_LAC_ESTABLISH;
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
        if (yysyntax_error_status == 0)
          yymsgp = yymsg;
        else if (yysyntax_error_status == -1)
          {
            if (yymsg != yymsgbuf)
              YYSTACK_FREE (yymsg);
            yymsg = YY_CAST (char *,
                             YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
            if (yymsg)
              {
                yysyntax_error_status
                  = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
                yymsgp = yymsg;
              }
            else
              {
                yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
                yysyntax_error_status = YYENOMEM;
              }
          }
        yyerror (&yylloc, result, scanner, yymsgp);
        if (yysyntax_error_status == YYENOMEM)
          goto yyexhaustedlab;
      }
    }

  yyerror_range[1] = yylloc;
  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
         error, discard it.  */

      if (yychar <= SQL_YYEOF)
        {
          /* Return failure if at end of input.  */
          if (yychar == SQL_YYEOF)
            YYABORT;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval, &yylloc, result, scanner);
          yychar = SQL_MENT_EMPTY;
        }
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:
  /* Pacify compilers when the user code never invokes YYERROR and the
     label yyerrorlab therefore never appears in user code.  */
  if (0)
    YYERROR;

  /* Do not reclaim the symbols of the rule whose action triggered
     this YYERROR.  */
  YYPOPSTACK (yylen);
  yylen = 0;
  YY_STACK_PRINT (yyss, yyssp);
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */

  /* Pop stack until we find a state that shifts the error token.  */
  for (;;)
    {
      yyn = yypact[yystate];
      if (!yypact_value_is_default (yyn))
        {
          yyn += YYSYMBOL_YYerror;
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
        YYABORT;

      yyerror_range[1] = *yylsp;
      yydestruct ("Error: popping",
                  YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp, result, scanner);
      YYPOPSTACK (1);
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  /* If the stack popping above didn't lose the initial context for the
     current lookahead token, the shift below will for sure.  */
  YY_LAC_DISCARD ("error recovery");

  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
  *++yyvsp = yylval;
  YY_IGNORE_MAYBE_UNINITIALIZED_END

  yyerror_range[2] = yylloc;
  ++yylsp;
  YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);

  /* Shift the error token.  */
  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;


/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;


#if 1
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here.  |
`-------------------------------------------------*/
yyexhaustedlab:
  yyerror (&yylloc, result, scanner, YY_("memory exhausted"));
  yyresult = 2;
  goto yyreturn;
#endif


/*-------------------------------------------------------.
| yyreturn -- parsing is finished, clean up and return.  |
`-------------------------------------------------------*/
yyreturn:
  if (yychar != SQL_MENT_EMPTY)
    {
      /* Make sure we have latest lookahead translation.  See comments at
         user semantic actions for why this is necessary.  */
      yytoken = YYTRANSLATE (yychar);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval, &yylloc, result, scanner);
    }
  /* Do not reclaim the symbols of the rule whose action triggered
     this YYABORT or YYACCEPT.  */
  YYPOPSTACK (yylen);
  YY_STACK_PRINT (yyss, yyssp);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp, result, scanner);
      YYPOPSTACK (1);
    }
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  if (yyes != yyesa)
    YYSTACK_FREE (yyes);
  if (yymsg != yymsgbuf)
    YYSTACK_FREE (yymsg);
  return yyresult;
}

#line 1386 "bison_parser.y"

/*********************************
 ** Section 4: Additional C code
 *********************************/

const char* ment_token_to_string(int tok) {
    switch (tok) {
        case SQL_SELECT: return "SELECT";
        case SQL_FROM:   return "FROM";
        case SQL_WHERE:  return "WHERE";
        case SQL_INSERT: return "INSERT";
        case SQL_INTO:   return "INTO";
        case SQL_VALUES: return "VALUES";
        case SQL_CREATE: return "CREATE";
        case SQL_TABLE:  return "TABLE";
        case SQL_DELETE: return "DELETE";
        case SQL_IDENTIFIER: return "IDENTIFIER";
        case SQL_STRING:     return "STRING";
        case SQL_INTVAL:     return "INT";
        case SQL_FLOATVAL:   return "FLOAT";
        case 0:              return "EOF";
        default:             return "UNKNOWN_TOKEN";
    }
}
